Skip to content
This repository

Allow FormLabel position to be defined in a configuration array #2542

Open
zfbot opened this Issue · 7 comments

4 participants

Zend Framework DevTeam Martin Keckeis George Cooksey Matthew Weier O'Phinney
Zend Framework DevTeam
Owner

Jira Information

Original Issue: ZF2-498
Issue Type: Improvement
Reporter: texdc
Created: 08/23/12
Assignee: weierophinney
Components: Zend\Form

Description

Currently, there is no way to define the position of FormLabels when elements are rendered in a collection or row. This is particularly relevant to checkbox, multiCheckbox and radio fields. By default, checkbox, multiCheckbox, and radio elements should append their label. Regardless, a '{{label_position}}' configuration option should be available and recognized by the FormCollection and FormRow helpers.

// inside Controller ...
$form->add(array(
   "name" => "remember",
   "type" => "Zend\Form\Element\Checkbox",
   "options" => array(
      "label" => "Remember Me",
      "label_position" => "append",
   ),
));
Zend Framework DevTeam
Owner

(Originally posted by: Michael Gallego on 09/05/12)

This is a good idea. I'll make a fix tomorrow for that.

EDIT : the only problem I can see is that this thing is relative to FormRow helper, so this means we are going to introduce something into the base Element that is used only by the FormRow helper. I'll talk to Matthew and cgmartin about that :).

Zend Framework DevTeam
Owner

(Originally posted by: cgmartin on 09/05/12)

We already have the label attributes attached to the base Element, so makes sense to me to be able to set label options on it as well.

Would it also be helpful to attach the FormElementError attributes (and options?) to the base Element? We run into the same kinds of limitations with rendering the errors as we do with the labels, in the context of FormRow.

Zend Framework DevTeam
Owner

(Originally posted by: texdc on 09/05/12)

My main goals for this in every context are:
1. Default (appended) rendering with no configuration for radio/checkbox elements
2. Custom rendering via configuration

I also agree with Chris' suggestion regarding errors.

The bottom line is that these elements should not be handled like other inputs when rendered.

Zend Framework DevTeam
Owner

This issue was ported from the ZF2 Jira Issue Tracker at
http://framework.zend.com/issues/browse/ZF2-498

Known GitHub users mentioned in the original message or comment:
@texdc, @weierophinney, @cgmartin

Martin Keckeis

@texdc @cgmartin this shouldn't be done in the configuration...IMO

For this are views and their helpers around.

If someone wants the labeled positioned every time somewhere else -> this should be done in their own view helper.

Can this get closed?

George Cooksey
texdc commented
Martin Keckeis

@texdc "jiein" (german: yes/no)...it depends.

You can also use label view helpers to accomplish this.
See here: http://framework.zend.com/manual/2.0/en/modules/zend.form.view.helpers.html#formlabel

I think it's difficult to draw here the line...What if you want to custom display the error messages and so on....should this be also part of the element declaration?

//Sidenote:
In ZF1 i also used a lot of direct complete form rendering, and in ZF2 i started to use view scripts and formRow and i couldn't be happier because the forms are now much better for the user...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.