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

#549 closed enhancement (fixed)

jForms: support of <group>

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

Description

Wouldn't it be interesting to be able to define groups in jforms. These groups would be translated to fieldsets.

I know we can do that in the template, but I think this would be interesting for generic controllers like jDaoCrud for example.

I am also also doing a generic controller for my work and I must create templates for each objects only to specify how data will be grouped in fieldsets.

What do you all think about it ?

Change History (11)

comment:1 follow-up: Changed 12 years ago by laurentj

No problem if you propose a solution for templates : how can we generate this fieldset ? For the moment, we cannot because formcontrols loops over all controls.. Suggest some new template plugins.

comment:2 in reply to: ↑ 1 Changed 12 years ago by doubleface

Replying to laurentj:

Suggest some new template plugins.

Well, I will try to find something usable in templates...

comment:3 follow-up: Changed 12 years ago by laurentj

  • Milestone set to Jelix 1.1 beta 1
  • Owner set to laurentj
  • Status changed from new to assigned

It's OK, I think how to do it. The same mecanism could be used for other future tags like <switch>, <repeat> etc..

I'm going to develop it, I need it for jbugTracker

comment:4 in reply to: ↑ 3 Changed 12 years ago by doubleface

Replying to laurentj:

It's OK, I think how to do it. The same mecanism could be used for other future tags like <switch>, <repeat> etc..

I'm going to develop it, I need it for jbugTracker

OK, was digging in jForms, and I am glad you have an idea how to do it !

comment:5 Changed 12 years ago by laurentj

  • Summary changed from Fieldsets in jForms to jForms: support of <group>

comment:6 Changed 12 years ago by laurentj

The syntax of group tag will be:

<group ref="foo">
    <label>The label of the group </label>

    <!-- all controls of the group -->
    <input .../>
    <othercontrol .../>
    ...
</group>

If we deactivate the group or if we mark it as readonly, all its 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 group</legend>
<table>
<tr><th><label>....here the label of the first control</th>
    <td>here the first control</td></tr>
etc.
</table>
</fieldset>

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

    {form_control_group 'ref_of_control', '<fieldset><legend>%s</legend><table>', '</table></fieldset>'}
      <tr><th>{ctrl_label}</th><td>{ctrl_control}</td>
    {/form_control_group}

this plugin loops over all child controls of the group. The second and third argument are the content before and after the list of controls. "%s" is replaced by the label of the group.

All comments are welcomed.

comment:7 Changed 12 years ago by bballizlife

I'm ok with that proposal as template plugins allow us to personnalize the output as we want. I also relly like the concept of inheritance of readonly and deactivate attributes.

comment:8 Changed 12 years ago by laurentj

It works on the experimental/jforms-group branch. I still have to create the form_control_group plugin.

comment:9 Changed 12 years ago by laurentj

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

landed into the trunk.

comment:10 Changed 12 years ago by laurentj

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