G
G
gachkydxvbgd2017-05-01 23:37:54
symfony
gachkydxvbgd, 2017-05-01 23:37:54

How to set up form symfony?

<div class="form-group">
                        <label class="col-sm-3 control-label" for="form-control-1">Название</label>
                        <div class="col-sm-9">
                            {{ form_row(categories_create_form.title) }}
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label" for="form-control-2">Password input</label>
                        <div class="col-sm-9">
                            <input id="form-control-2" class="form-control" type="password" value="test.1234">
                        </div>
                    </div>

public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('title', TextType::class, ['attr' => ['class' => 'form-control']])
            ->add('save', SubmitType::class, ['label' => 'Create', 'attr' => ['class' => 'btn btn-primary']]);
    }

How to remove it?5721e8bc1cc44d81af987cd3050fe43b.png

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexey Skobkin, 2017-05-02
@gachkydxvbgd

symfony.com/doc/current/form/form_customization.ht...

V
Victor Diditsky, 2017-05-04
@GhostSt92

Instead {{ form_row(categories_create_form.title) }}
, use {{ form_widget(categories_create_form.title) }}
To display the field name separately -{{ form_label(categories_create_form.title) }}

S
shagguboy, 2017-05-02
@shagguboy

->add('title', TextType::class, ['attr' => [
'class' => 'form-control'
'label' => 'blablabla'
]])

A
Alexander Kuznetsov, 2017-05-04
@DarkRaven

If my memory serves me, attribute

[
...
'label' => false
...
]

regulates whether to display the Label for the control or not.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question