Thanks very much, I appreciate the guidance

On Tuesday, May 21, 2019 at 12:38:15 PM UTC-4, Alessandro Molina wrote:
>
> Is https://tw2core.readthedocs.io/en/develop/forms/#dynamic-forms what 
> you are looking for? How to dynamically add/remove fields to a TW2 form?
>
> When you have such more complex customization needs I start to feel it's 
> usually best to switch to hand made TW2 forms where you can inject complex 
> logic in prepare and post_define.
>
> You might be able to do what you want btw, by providing a `
> __base_widget_type__` to the __form_options__
> That will allow you to provide a subclass of tw2.forms.TableForm (or 
> anything else) with a prepare method that hides/removes some fields based 
> on `tg.request.params` or whatever condition you need.  Look at that tw2 
> docs link, it should explain how to edit the fields of a form during a 
> request and then it should just be a matter of passing your own custom 
> subclass of Form as the __base_widget_type__
>
>
>
>
> On Sat, May 18, 2019 at 4:33 PM Dax Mitchell <[email protected] 
> <javascript:>> wrote:
>
>>
>>
>> Hi,
>>
>> We have a setup like below.  We would really like to hide the password 
>> and verify_password fields in the form based on some some conditions 
>> which will vary based on parameters set elsewhere (sometimes it's very 
>> confusing to show those fields).
>>
>> The closest thing I could find is this post 
>> <https://groups.google.com/forum/#!searchin/turbogears/tw2.dynform%7Csort:date/turbogears/e9Lvs0FYUVE/YwoKjUmIwfgJ>,
>>  
>> which suggests "copying the dynamic field declaration inside the 
>> __field_widgets__ property" 
>>
>> It would be very helpful to see an example, or any other suggestions 
>> would be very much appreciated.
>>
>>
>>
>> class UserAdminConfig(UserControllerConfig):
>>     ...
>>
>>     class defaultCrudRestController(ResourceManagerCrudRestController):
>>        ...
>>         __form_options__ = {
>>             '__require_fields__': ['user_name', 'email_address'],
>>             '__omit_fields__': ['_password', 'created', '_groups', 
>> '_reset_password_key',
>>                                 'reset_password_key', 
>> 'reset_password_expires'],
>>             '__hide_fields__': ['user_id'],
>>             '__field_order__': ['user_name', 'email_address', 
>> 'display_name', 'groups',
>>                                 'password', 'verify_password'],
>>             '__field_widget_types__': addopts(user_name=TextField,
>>                                               email_address=TextField,
>>                                               display_name=TextField),
>>             '__field_widget_args__': 
>> addopts(password=CUSTOM_FORM_FIELD_OPTIONS)
>>         }
>>
>> -- 
>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/turbogears.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/turbogears/0d592ada-62b6-4467-93ab-5ca7f8a619a8%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/turbogears/0d592ada-62b6-4467-93ab-5ca7f8a619a8%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/turbogears/441f343f-5d58-4a7d-aff6-d49ba13a473a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to