Issues

ZF2-498: Allow FormLabel position to be defined in a configuration array

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",
   ),
));

Comments

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 :).

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.

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.

This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit: https://github.com/zendframework/zf2/issues/2542