cakephp3-bootstrap-helpers icon indicating copy to clipboard operation
cakephp3-bootstrap-helpers copied to clipboard

Group multiple input in the same row

Open azerto00 opened this issue 9 years ago • 2 comments

Hello there,

First, thanks for releasing this Plugin.

Is is possible to group multiple input inside the same row ? For exemple, if I want to show 2 input in the same row, I use the following code :

<div class="row">
    <?= $this->Form->input('name', [
        "label" => false,
        "type" => "text",
        'templates' => [
            'inputContainer' => '<div class="col-lg-6">{{content}}</div>'
        ],
    ]);
    ?>
    <?= $this->Form->input('surname', [
        "label" => false,
        "type" => "text",
        'templates' => [
            'inputContainer' => '<div class="col-lg-6">{{content}}</div>'
        ],]);
    ?>
</div>

Am i missing something or is the only way ?

Thanks in advance

azerto00 avatar Jan 26 '16 19:01 azerto00

There is no built-in way to create form with multiple column, but you should not modify the inputContainer template, or at least keep the standard class.

The right way to do what you want is to insert input into a layout:

<div class="row">
  <div class="col-lg-6">
    <?= $this->Form->input('name', [
               "label" => false,
               "type" => "text"
     ]); ?>
  </div>
  <div class="col-lg-6">
    <?= $this->Form->input('surname', [
               "label" => false,
               "type" => "text"
     ]); ?>
  </div>
</div>

Holt59 avatar Jan 26 '16 19:01 Holt59

CakePHP has a inputs methods to generate multiple inputs in a fieldset. I will probably extend it to all multiple columns in a future version, so something like that:

echo $this->Form->inputs([
    'name' => [
        'label' => false,
        'type'  => text
    ],
    'surname' => [
        'label' => false,
        'type'  => text
    ]
]);

Would generate:

<fieldset class="row">
    <div class="col-md-6">
        ...
    </div>
    <div class="col-md-6">
        ...
    </div>
</fieldset>

Holt59 avatar Feb 29 '16 10:02 Holt59