Hello,
I would like Peppercorn or Deform to ignore some HTML fields when
validating a form. I have a Deform widget (here below called
"ExtendedAutocompleteInputWidget") that has two HTML fields: a visible
text input ('person_autocomplete') and an hidden text input ('person'),
the former being for presentation purpose only, the latter holding the
value to be stored), and the following schema:
--- 8< ---
class Person(SequenceSchema):
person = SchemaNode(
String(),
widget=ExtendedAutocompleteInputWidget())
class DemoSchema(Schema):
persons = Person(widget=SequenceWidget(min_len=1))
--- 8< ---
I get the following POSTed items:
('__start__', u'persons:sequence'),
('person', u'1'),
('person_autocomplete', u'John Smith'),
('person', u'2'),
('person_autocomplete', u'Jane Doe'),
('__end__', u'persons:sequence')
Currently, Peppercorn "eats" all HTML fields and transforms this into a
record of 4 items that are all mapped to the 'persons' sequence. I would
like Deform/Peppercorn to only record 2 items (those named 'person' --
like the field). Am I misusing SequenceSchema? (Note that this "bug"
does not appear when the two-HTML-field widget appears in a MappingSchema.)
If I am not misusing anything, how could I work around or fix that?
For now, I call a cleaning method before passing the POSTed data to
'Form.validate' but I would like to move this responsibility to the
widget itself, Deform or Peppercorn.
I suppose that the best option would be to ask each widget if it needs
to remove meaningless HTML fields that it introduced. In
'Field.validate()', before passing the controls to 'peppercorn.parse()',
we could iterate over each widget of the schema and call
'widget.ignore_fields()' if the widget defines such a method. Another
(much easier) option would be to make Peppercorn ignore some fields, for
example those whose name ends with '__no_peppercorn__'. Any idea or
preference?
Cheers,
--
Damien Baty
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.