is not used any more and exists only for history. Post new tickets on the Github account. n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#564 closed enhancement (fixed)

jforms: support of <choice>

Reported by: laurentj Owned by: laurentj
Priority: normal Milestone: Jelix 1.1 beta 1
Component: jelix:forms Version: 1.0.3
Severity: normal Keywords:
Cc: Blocked By:
Blocking: Documentation needed: no
Hosting Provider: Php version:


<choice> is an element to allow to choice between groups of control. It is like <radiobuttons>, but you can have fields on each items. An exemple of this type of control is the "action" group of control on a ticket (see below ;-))

<choice ref="action">

   <item value="new">
       <label>Leave as new</label>
   <item value="ASS">
       <label>accept ticket</label>
   <item value="ASS">
       <label>resolve as</label>
       <menulist ref="resolution">
            <item value="fix">fixed</item>
            <item value="inv">invalid</item>
            <item value="wtf">won't fix</item>
   <item value="REASS">
       <label>Reassign to</label>
       <input ref="assignee">

Change History (9)

comment:1 Changed 13 years ago by laurentj

Improvements on specification.

the choice element could have a label element. If we deactivate the choice or if we mark it as readonly, all its sub-controls will be deactivated or readonly.

For the template part:

If the control is displayed throw a formcontrols loop or by formfull, it will generate a default html content like this:

<fieldset><legend>The label of the choice</legend>
<ul><input type="radio" value="new"><label>Leave as new</label></li>
<li><input type="radio" value="ACC"><label>accept ticket</label></li>
<li><input type="radio" value="CLO"><label>resolve as</label>


If we want to personnalize the output, we would use the form_control_choice plugin. Example which generates the same content as the default html generation like above:

    {form_control_choice 'action', '<fieldset><legend>%s</legend><ul>', '</ul></fieldset>'}
        <li> {ctrl_item}
            {ctrl_label} {ctrl_control}

this plugin loops over all items of the choice. And we should use form controls to loop over each controls of an item. The second and third argument of form_control_choice are the content before and after the list of items. "%s" is replaced by the label of the choice. ctrl_item displays the item (radio button + its label).

All comments are welcomed.

comment:2 Changed 13 years ago by laurentj

  • Owner set to laurentj
  • Status changed from new to assigned

comment:3 Changed 13 years ago by bballizlife

I'm ok with that. But here, which kind of value will we get for "action" ?

comment:4 Changed 13 years ago by laurentj

The value of "action" is the value of the "value" attribute of the selected item. With this value, you know which controls are selected and so you can take their values. Controls which are in the unselected items are set to readonly. And I think there will a method on the "choice" control to get selected child controls.

comment:5 Changed 13 years ago by laurentj

  • Milestone set to Jelix 1.1 beta 1

comment:6 Changed 13 years ago by laurentj

Implementation finished in the jforms-group branch.

comment:7 Changed 13 years ago by laurentj

  • Resolution set to fixed
  • Status changed from assigned to closed

Landed into the trunk.

comment:8 Changed 13 years ago by laurentj

  • Documentation needed set
Note: See TracTickets for help on using tickets.