Opened 19 years ago

Last modified 15 years ago

#607 closed enhancement

IDEA: admin option to show/hide fields — at Version 2

Reported by: Wilson Miner Owned by: Adrian Holovaty
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Wilson Miner)

Concept: An admin option that specifies a list of fields to show/hide based on the value of another field.

Example: An "I like cake" checkbox that, when checked, shows two previously hidden text fields "Favorite cake" and "Favorite frosting".

Code Example:

admin.switch = [('likes_cake', {'True': ['favorite_cake', 'favorite_frosting']})]

You could also tie this to a particular value of a select field:

admin.switch = [('gender', {'M': ['favorite_sport'], 'F': ['favorite_soap_opera']})]

Unsolved issues:

  • Need some place to specify the initial state of the targeted fields (visible or hidden). Default (and most common case) would be hidden, but there are cases where this needs to be reversed.
  • All hiding and should happen in javascript, so fields don't get hidden that can't be turned back on with javascript disabled. The switch option could also tie into the validation framework so unnecessary fields (meant to be hidden) don't get filled in even when javascript is off.
  • Any other ideas?

Change History (2)

comment:1 by Adrian Holovaty, 19 years ago

To be consistent, the examples should both take dictionaries. (And they should take a list, so that you can have more than one switch per admin screen.)

admin.switch = [('likes_cake', {'True': ['favorite_cake', 'favorite_frosting']})]
admin.switch = [('gender', {'M': ['favorite_sport'], 'F': ['favorite_soap_opera']})] 

It's a bit syntax heavy, but I like the idea.

comment:2 by Wilson Miner, 19 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top