Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicated label class #325

Open
nachitox opened this issue Aug 20, 2020 · 0 comments
Open

Duplicated label class #325

nachitox opened this issue Aug 20, 2020 · 0 comments
Labels

Comments

@nachitox
Copy link

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>'
	]
]) ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants