Ticket #564 (closed enhancement: fixed)

Opened 3 months ago

Last modified 1 day ago

jforms: support of <choice>

Reported by: laurentj Assigned to: laurentj
Priority: normal Milestone: Jelix 1.1 beta 1
Component: jelix:forms Version: 1.0.3
Severity: normal Keywords:
Cc: Php version:
Review: Hosting Provider:
Documentation needed: 1 Blocking:

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

05/02/08 16:45:03 changed 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.

05/02/08 17:04:11 changed by laurentj

  • owner set to laurentj.
  • status changed from new to assigned.

05/02/08 17:32:37 changed by bballizlife

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

05/03/08 15:12:21 changed 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.

07/16/08 00:14:44 changed by laurentj

  • milestone set to Jelix 1.1 beta 1.

07/19/08 15:54:44 changed by laurentj

Implementation finished in the jforms-group branch.

07/20/08 00:11:36 changed by laurentj

  • status changed from assigned to closed.
  • resolution set to fixed.

Landed into the trunk.

07/20/08 01:14:06 changed by laurentj

  • docneeded set to 1.
Download in other formats: Comma-delimited Text Tab-delimited Text RSS Feed