[forms] work-in-progress: let guess_field and RichTextField.get_format_field handle eidparam of meta fields
--- a/web/formfields.py Wed Aug 05 09:05:40 2009 +0200
+++ b/web/formfields.py Wed Aug 05 09:10:32 2009 +0200
@@ -270,6 +270,7 @@
fkwargs['choices'] = fcstr.vocabulary(req=req)
fkwargs['internationalizable'] = True
fkwargs['initial'] = lambda f: f.form_field_format(self)
+ fkwargs['eidparam'] = self.eidparam
field = StringField(name=self.name + '_format', **fkwargs)
req.data[self] = field
return field
@@ -494,6 +495,7 @@
help = rschema.rproperty(targetschema, eschema, 'description')
kwargs['required'] = card in '1+'
kwargs['name'] = rschema.type
+ kwargs['eidparam'] = True
kwargs.setdefault('help', help)
if rschema.is_final():
if skip_meta_attr and rschema in eschema.meta_attributes():
--- a/web/views/forms.py Wed Aug 05 09:05:40 2009 +0200
+++ b/web/views/forms.py Wed Aug 05 09:10:32 2009 +0200
@@ -371,24 +371,20 @@
self.form_renderer_id, self.req, rset=self.rset, row=self.row,
col=self.col, entity=self.edited_entity)
- def form_build_context(self, values=None):
- """overriden to add edit[s|o] hidden fields and to ensure schema fields
- have eidparam set to True
-
- edit[s|o] hidden fields are used to indicate the value for the
- associated field before the (potential) modification made when
- submitting the form.
- """
- eschema = self.edited_entity.e_schema
- for field in self.fields[:]:
- for field in field.actual_fields(self):
- fieldname = field.name
- if fieldname != 'eid' and (
- (eschema.has_subject_relation(fieldname) or
- eschema.has_object_relation(fieldname))):
- field.eidparam = True
- self.fields.append(HiddenInitialValueField(field))
- return super(EntityFieldsForm, self).form_build_context(values)
+## def form_build_context(self, values=None):
+## """overriden to add edit[s|o] hidden fields and to ensure schema fields
+## have eidparam set to True
+## """
+## eschema = self.edited_entity.e_schema
+## for field in self.fields[:]:
+## for field in field.actual_fields(self):
+## fieldname = field.name
+## if fieldname != 'eid' and (
+## (eschema.has_subject_relation(fieldname) or
+## eschema.has_object_relation(fieldname))):
+## # XXX why do we need to do this here ?
+## field.eidparam = True
+## return super(EntityFieldsForm, self).form_build_context(values)
def form_field_value(self, field, load_bytes=False):
"""return field's *typed* value