Add additional properties to the choices attribute in field class for Form objects

Registered by mariam john

The ChoiceField class has an attribute choices which takes a list of 2 element tuple by default.

self.field[<field name>].choices = ([
                                                                 (option_value1, option_label1),
                                                                 (option_value2, option_label2)
                                                               ])

This blueprint describes a way to extend this to define additional properties or attributes for each choice within the choices list. These additional attributes for each choice can be any HTML global attributes defined in a dictionary. For example, to define a help text for each choice:

self.field[<field name>].choices = ([
                                                                 (option_value1, option_label1, {'title': 'help text 1'}),
                                                                 (option_value2, option_label2, {'title': 'help text 2'})
                                                               ])

Blueprint information

Status:
Complete
Approver:
None
Priority:
Undefined
Drafter:
mariam john
Direction:
Needs approval
Assignee:
mariam john
Definition:
Approved
Series goal:
None
Implementation:
Implemented
Milestone target:
None
Started by
Rob Cresswell
Completed by
Rob Cresswell

Related branches

Sprints

Whiteboard

Gerrit topic: https://review.openstack.org/#q,topic:bp/add-attributes-to-form-field-choices,n,z

Addressed by: https://review.openstack.org/94450
    Add attributes to cell in a table depending on data

Addressed by: https://review.openstack.org/96879
    Add additional attributes to choices in ChoiceField

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.