Thanx for the pointer. Regarding the schema, I think my approach is
ok. "add" is part of the public API of a SchemaNode, and order in the
schema doesn't matter. Order does only matter for the rendering of the
Form, so my question is more related to my messing with Form.children.
I also want to manipulate the already instantiated Form, so the
self.children = []
self.__dict__.update(kw)
for child in schema.children:
self.children.append(Field(child,
renderer=renderer,
counter=self.counter,
resource_registry=resource_registry,
**kw))
in Field.__init__ has already taken place (and so manipulating the
order in the schema doesn't help anymore). I guess my question boils
down to whether I can regard the "children" list on deform.Field as
public API.
On Mon, Mar 5, 2012 at 5:21 PM, Mariano Mara <[email protected]> wrote:
> On 05.03.12 08:13, Robert Forkel wrote:
>> Hi,
>> i have the following Problem: I want to add fields to a form at
>> arbitrary positions after the form instance has been initialized (this
>> is intended as a configuration mechanism - a default form can be
>> manipulated by custom packages).
>> I didn't find a public API method to do this, but came up with the
>> following:
>>
>> myform = Form(MySchema(), buttons=[])
>>
>> node = SchemaNode(String(), name='new', description='well, new')
>>
>> myform.schema.add(node)
>> myform.children.insert(1, Field(node, renderer=myform.renderer,
>> counter=myform.counter,
>> resource_registry=myform.default_resource_registry))
>>
>> obviously, that's a bit of a hack, but wouldn't look too bad if placed
>> in a form method "insert_node" or something the like. How fragile
>> would this be, i.e. how likely is it, the API it relies on will
>> change?
>> regards,
>> robert
>>
>
> Check out the following discussion [1] to see if it's of help.
>
> Regards
>
> [1] https://groups.google.com/forum/#!topic/pylons-discuss/55FXAMkde4w
>
> --
> 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.
>
--
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.