I think https://turbogears.readthedocs.io/en/latest/cookbook/sprox.html#custom-dropdown-field-names is what you are looking for (option was recently renamed to possible_field_names but works the same way) You can set it in __form_options__ for the admin crudControllerConfig and have the generated forms use that as their preview field in single selects.
For users and groups it works automatically because sprox tries to be smart in detecting the proper field to use and one of the heuristics is to grab a field that is named "something_name" so group_name gets picked. On Thu, May 24, 2018 at 3:06 PM Daniel Latzer <[email protected]> wrote: > Hello > > I've created two tables in an m:n relationship: > > Activity (id, name) > EventDates (id, date) > > and linked these two using a sqlalchemy `relation`, mapping EventDates as > `event_dates` to Activity. > > I want to create Activities that can take on one or more EventDates. > Using the admin (and also a form generated with a `CrudRestController` as > seen here > <http://turbogears.readthedocs.io/en/latest/cookbook/Crud/index.html#custom-crudrestcontroller>), > the generated Multi-Select widget in the new-Activity Form just displays me > the primary key of the EventDate entries. I'd rather have it display the > date of the EventDate entries. > > I've inherited this application and am not really familiar with > Turbogears. Looking at some already existing models that are tied in with > `TGAuthMetadata` i can see in the Admin that there is basically the same > thing going on with User <-> Group <-> Permissions, and in these forms the > user_name, group_name or permission_name get displayed in the Multi-Select > and I cannot figure out how that has been achieved. > > So basically if I have this: > > class ActivityAddForm(AddRecordForm): > __model__ = Activity > __omit_fields__ = ['id'] > event_dates = ??? # this has an m:n relation to EventDate > > > How do i get the resulting Multi-Select to render something different than > the primary key of EventDate? Is it derived from the model? Is it > configured somewhere? > > I've been messing around with `PropertyMultipleSelectField`, but could not > figure out how to properly configure it to pass it as `event_dates`. > > Thanks for your time. > > -- > You received this message because you are subscribed to the Google Groups > "TurboGears" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/turbogears. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "TurboGears" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/turbogears. For more options, visit https://groups.google.com/d/optout.

