-
-
Notifications
You must be signed in to change notification settings - Fork 95
Add option for different label rendering for radio buttons #102
base: master
Are you sure you want to change the base?
Conversation
Don't use element label options if `global-label-attributes` option is FALSE
Don't use element label options if `global-label-attributes` option is not FALSE
Revert changes and change attribute parsing for proper rendering
Don't call \Zend\Form\LabelAwareInterface::setLabelAttributes, if attributes are empty
I'm not sure that I understand the goal of this pull request. Here is the rendering with the option set to false : http://jsfiddle.net/neilime/u33tkt85/. Is it right that the label is on that position ? |
You are right that setting this option to The purpose of this PR is to allow proper rendering of a global label in horizontal forms for radio buttons (See example "Global Label (true)" in "Testform"). The other way around is just nice to have. Configs used for examples:<?php
return array(
'forms' => array(
'testform' => array(
'elements' => array(
array(
'spec' => array(
'name' => 'text',
'type' => 'Text',
'options' => array(
'label' => 'Text',
'column-size' => 'sm-9',
'label_attributes' => array(
'class' => 'col-sm-3',
),
),
),
),
array(
'spec' => array(
'name' => 'radio',
'type' => 'Radio',
'options' => array(
'label' => 'Global Label (null)',
'value_options' => array(
'single' => 'First',
'pair' => 'Second',
'third' => 'Third',
),
'column-size' => 'sm-9',
'label_attributes' => array(
'class' => 'col-sm-3',
),
'global-label-attributes' => null,
),
),
),
array(
'spec' => array(
'name' => 'radio',
'type' => 'Radio',
'options' => array(
'label' => 'Global Label (true)',
'value_options' => array(
'single' => 'First',
'pair' => 'Second',
'third' => 'Third',
),
'column-size' => 'sm-9',
'label_attributes' => array(
'class' => 'col-sm-3',
),
'global-label-attributes' => true,
),
),
),
array(
'spec' => array(
'name' => 'radio',
'type' => 'Radio',
'options' => array(
'label' => 'Global Label (false)',
'value_options' => array(
'single' => 'First',
'pair' => 'Second',
'third' => 'Third',
),
'column-size' => 'sm-9',
'label_attributes' => array(
'class' => 'col-sm-3',
),
'global-label-attributes' => false,
),
),
),
array(
'spec' => array(
'name' => 'textarea',
'type' => 'Textarea',
'options' => array(
'label' => 'Textarea',
'column-size' => 'sm-9',
'label_attributes' => array(
'class' => 'col-sm-3',
),
),
),
),
),
),
),
); <?php
return array(
'forms' => array(
'labelform' => array(
'elements' => array(
array(
'spec' => array(
'name' => 'text',
'type' => 'Text',
'options' => array(
'label' => 'Text',
),
),
),
array(
'spec' => array(
'name' => 'radio',
'type' => 'Radio',
'options' => array(
'label' => 'Global Label (null)',
'value_options' => array(
'single' => 'First',
'pair' => 'Second',
'third' => 'Third',
),
'label_attributes' => array(
'class' => 'label label-info',
),
'global-label-attributes' => null,
),
),
),
array(
'spec' => array(
'name' => 'radio',
'type' => 'Radio',
'options' => array(
'label' => 'Global Label (true)',
'value_options' => array(
'single' => 'First',
'pair' => 'Second',
'third' => 'Third',
),
'label_attributes' => array(
'class' => 'label label-info',
),
'global-label-attributes' => true,
),
),
),
array(
'spec' => array(
'name' => 'radio',
'type' => 'Radio',
'options' => array(
'label' => 'Global Label (false)',
'value_options' => array(
'single' => 'First',
'pair' => 'Second',
'third' => 'Third',
),
'label_attributes' => array(
'class' => 'label label-info',
),
'global-label-attributes' => false,
),
),
),
array(
'spec' => array(
'name' => 'textarea',
'type' => 'Textarea',
'options' => array(
'label' => 'Textarea',
),
),
),
),
),
),
); |
OK, I got it. Please, can you update the readme file to explain the behavior of your improvment |
I'm waiting for your update of the readme file to merge your pull request |
@BreyndotEchse Are you planning on fixing the last things on this? Otherwise I might take over it since I'm in need of the same feature. |
Sorry. Don't have the time at the moment. |
Adds an option to allow different rendering of label attributes for radio labels.
Examples:
Config:
null (default/current behavior)
true
false
Fix
Fixes #97