Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
I need a dynamically filled SingleSelectField
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Moritz Schlarb  
View profile  
 More options May 30 2012, 1:06 pm
From: Moritz Schlarb <mosch...@metalabs.de>
Date: Wed, 30 May 2012 10:06:59 -0700 (PDT)
Local: Wed, May 30 2012 1:06 pm
Subject: I need a dynamically filled SingleSelectField

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
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 and https://gist.github.com/2830475


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Oliver  
View profile  
 More options Apr 4, 11:06 am
From: Oliver <dief...@gmail.com>
Date: Thu, 4 Apr 2013 08:06:02 -0700 (PDT)
Local: Thurs, Apr 4 2013 11:06 am
Subject: Re: I need a dynamically filled SingleSelectField

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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul Johnston  
View profile  
 More options Apr 4, 11:07 am
From: Paul Johnston <p...@pajhome.org.uk>
Date: Thu, 4 Apr 2013 16:07:22 +0100
Local: Thurs, Apr 4 2013 11:07 am
Subject: Re: [TW] Re: I need a dynamically filled SingleSelectField

Hi,

You may also find DbSingleSelectField in tw2.sqla useful for this.

Paul


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »