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

Opened 12 years ago

Closed 12 years ago

Last modified 12 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:

Description

<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>
   <item value="ASS">
       <label>accept ticket</label>
   </item>
   <item value="ASS">
       <label>resolve as</label>
       <menulist ref="resolution">
            <label>resolution</label>
            <item value="fix">fixed</item>
            <item value="inv">invalid</item>
            <item value="wtf">won't fix</item>
       </menulist>
   </item>
   <item value="REASS">
       <label>Reassign to</label>
       <input ref="assignee">
          <label>assignee</label>
       </input>
   </item>
</choice>

Change History (9)

comment:1 Changed 12 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>
    <label>resolution</label><select>...</select>
    </li>

</ul>
</fieldset>

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}
        {form_controls}
            {ctrl_label} {ctrl_control}
        {/form_controls}
        </li>
    {/form_control_group}

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 12 years ago by laurentj

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

comment:3 Changed 12 years ago by bballizlife

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

comment:4 Changed 12 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 12 years ago by laurentj

  • Milestone set to Jelix 1.1 beta 1

comment:6 Changed 12 years ago by laurentj

Implementation finished in the jforms-group branch.

comment:7 Changed 12 years ago by laurentj

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

Landed into the trunk.

comment:8 Changed 12 years ago by laurentj

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