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 for fields #388

Open
oldy777 opened this issue Nov 2, 2017 · 2 comments
Open

Group for fields #388

oldy777 opened this issue Nov 2, 2017 · 2 comments

Comments

@oldy777
Copy link

oldy777 commented Nov 2, 2017

Can I somehow add field in group? For example

$this->addGroup('my_group1', ['label' => 'My group'], function(){
    $this->add('text1', 'text');
})
$this->addGroup('my_group2', ['label' => 'My group2'], function(){
    $this->add('text2', 'text');
})

and render it

form_group('my_group1');
form_group('my_group2');

Now I try to do it with form type

$this->add('group', 'form', ['class'=>Myform::class])

But I'm facing with big problem, all names become name="form_name[field_name]". And no way to make simple name="field_name"

And another question, how can I add field after field in nested form?

$this->add('form_field', 'form', ['class'=>Myform::class])
$this->addAfter(''form_field.title', 'subtitle', 'text);
@kristijanhusak
Copy link
Owner

What does addGroup() do?

You can compose forms with the compose() method on the Form class, which will append fields from one form to another. http://kristijanhusak.github.io/laravel-form-builder/form/methods-and-properties.html#compose

@oldy777
Copy link
Author

oldy777 commented Nov 21, 2017

@kristijanhusak it must work like form type, but without nested names. For example

$this->addGroup('my_group1', ['label' => 'My group'], function(){
    $this->add('text1', 'text');
    $this->add('text2', 'text');
})

form_group('my_group1');

will give

<input name="text1" />
<input name="text2" />

This allows display the form fields more flexibly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants