Skip to content

Duplicated label class  #325

@nachitox

Description

@nachitox

This is a: bug

  • BootstrapUI Version: 1.4.2
  • Platform and Target: CakePHP 3.9.1

What you did

<?= $this->Form->control('position_tab', [
	'type' => 'select',
	'label' => [
		'text' => 'Review tab position',
		'class' => 'col-xs-9'
	],
	'options' => $positionsTab,
	'templates' => [
		'select' => '<div class="col-xs-3"><select name="{{name}}"{{attrs}}>{{content}}</select></div>'
	]
]) ?>

Expected Behavior

<div class="form-group select">
   <label class="col-xs-9 control-label" for="position-tab">Review tab position</label>
   <div class="col-xs-3">
      <select name="position_tab" class="validator validator form-control" id="position-tab">
         <option value="right" selected="selected">Right</option>
         <option value="left">Left</option>
      </select>
   </div>
</div>

Or at least, it works like this on 0.6.2

Actual Behavior

<div class="form-group select">
   <label class="control-label col-md-2" class="col-xs-9" for="position-tab">Review tab position</label>
   <div class="col-md-6">
      <div class="col-xs-3">
         <select name="position_tab" class="validator validator form-control" id="position-tab">
            <option value="right" selected="selected">Right</option>
            <option value="left">Left</option>
         </select>
      </div>
   </div>
</div>

I can understand the extra div caused by formGroup but why the label.class is not being applied?

Hack to fix it

<?= $this->FormValidator->control('position_tab', [
	'type' => 'select',
	'label' => 'Review tab position',
	'options' => $positionsTab,
	'templates' => [
		'formGroup'	=> '{{label}}<div class="col-xs-3">{{input}}</div>',
		'label'		=> '<label class="col-xs-9 control-label"{{attrs}}>{{text}}</label>'
	]
]) ?>

I want to avoid setting templates.label when there's no need. I think this should work:

<?= $this->FormValidator->control('position_tab', [
	'type' => 'select',
	'label' => [
		'text' => 'Review tab position',
		'class' => 'col-xs-9'
	],
	'options' => $positionsTab,
	'templates' => [
		'formGroup'	=> '{{label}}<div class="col-xs-3">{{input}}</div>'
	]
]) ?>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions