Setting the value for defaults

36 views
Skip to first unread message

Jason

unread,
Jun 7, 2012, 11:50:50 AM6/7/12
to forma...@googlegroups.com
Is there a reason that field.set cannot accept a value argument and field.value cannot be set directly?

When rendering the form I need to set a SelectFieldRenderer to a specific value. This is used as the default when adding a new item. Currently I have subclassed SelectFieldRenderer and in render() it checks to see if a default key was added to metadata. This is a weird shoehorn for something that should be possible already. 

I could submit a patch, but I don't know whether it should allow setting value directly (through field.set(value=bleh) ) or if it should add a new attribute to the field instance called default_value.



--Jason

Gaël Pasgrimaud

unread,
Jun 15, 2012, 10:46:13 AM6/15/12
to forma...@googlegroups.com
You can always set the field value by accessing the model. fs.model.attr = 'foo'

But I have no objection to add a value argument to set()
> --
> You received this message because you are subscribed to the Google Groups
> "FormAlchemy" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/formalchemy/-/cEeTYAUwb7EJ.
> To post to this group, send email to forma...@googlegroups.com.
> To unsubscribe from this group, send email to
> formalchemy...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/formalchemy?hl=en.
Reply all
Reply to author
Forward
0 new messages