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

Group multiple input in the same row #70

Open
azerto00 opened this issue Jan 26, 2016 · 2 comments
Open

Group multiple input in the same row #70

azerto00 opened this issue Jan 26, 2016 · 2 comments

Comments

@azerto00
Copy link

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

@Holt59
Copy link
Collaborator

Holt59 commented Jan 26, 2016

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
Copy link
Collaborator

Holt59 commented Feb 29, 2016

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 Holt59 self-assigned this Apr 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants