On Thu, Apr 4, 2013 at 4:06 PM, Oliver <dief
...@gmail.com> wrote:
> I got the same problem and from the code point of view the easiest was for
> me was to deal with _iterate_options
> I had to put a "self" in the lambda args which references the instance of
> DynamicSelectField...
> I hope this is useful for you
> class DynamicSelectField(twf.SingleSelectField):
> def _iterate_options(self, optlist):
> if hasattr(optlist, '__call__'):
> for o in optlist():
> yield o
> else:
> for o in super(DynamicSelectField,
> self)._iterate_options(optlist):
> yield o
> class ContentForm(twf.TableForm):
> id = twf.HiddenField
> page_id = DynamicSelectField(options=lambda self: ((p.id, p) for p in
> Page.query))
> Am Mittwoch, 30. Mai 2012 19:06:59 UTC+2 schrieb Moritz Schlarb:
>> Dear ToscaWidgetters,
>> I have a problem here and although threebean already tried to help me, it
>> does not work yet!
>> This is the offending piece of code:
>> https://gist.github.com/**2837623 <https://gist.github.com/2837623>
>> which just throws:
>> AttributeError: 'SubmissionForm_d' object has no attribute 'language_id'
>> It's a widget that needs the language_id selection field filled with
>> values, but not with all values from the Database (then
>> tw2.sqla.DbSelectionField would suffice) but with ones filtered by the
>> SQLAlchemy query you see in the prepare method. It's dependent on the
>> values the form gets displayed with, especially the associated assignment
>> In tw 0.9, I just prepared the options list for the SingleSelectField in
>> my Controller and passed it via child_args to the widget, but that doesn't
>> seem to work anymore!
>> If someone has a working solution for me, I'd be glad to get some advice
>> or a fork of the gist!
>> Cheers,
>> Moritz
>> PS: Some older approaches by threebean and me: https://gist.github.com/**
>> 2790405 <https://gist.github.com/2790405> and https://gist.**
>> github.com/2830475 <https://gist.github.com/2830475>
>> --
> You received this message because you are subscribed to the Google Groups
> "ToscaWidgets-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to toscawidgets-discuss+unsubscribe@googlegroups.com.
> To post to this group, send email to toscawidgets-discuss@googlegroups.com
> .
> Visit this group at
> http://groups.google.com/group/toscawidgets-discuss?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.