0

如何调整我的表单以实现引导程序?

我创建表单的功能是:

private function createCreateForm(User $entity)
{

    $form = $this->createFormBuilder($entity, array(
        'action' => $this->generateUrl('user_create'),
        'method' => 'POST',
    ))
    ->add('username')
    ->add('email')
    ->add('password', 'repeated', array(
       'first_name'  => 'password',
       'second_name' => 'confirm',
       'type'        => 'password',
    ))
    ->add('submit', 'submit', array('label' => 'Create'))
    ->getForm();
    return $form;
}

我的看法是

{{ form_start(form) }}
    {{ form_row(form.username, { 'attr': {'class': 'form-control', 'placeholder': 'Imię oraz nazwisko'} }) }}
    {{ form_row(form.password, { 'attr': {'class': 'form-control', 'placeholder': 'Password'} }) }}

它适用于用户名但不适用于密码,一些建议?我怎样才能创建我们自己的表格?

我的引导程序:

<form action="#" class="form-horizontal">
    <div class="form-body">
        <div class="form-group">
            <label  class="col-md-3 control-label">NAME</label>
            <div class="col-md-4">
                <input type="text" class="form-control" placeholder="NAME
            </div>
        </div>
    <div class="form-actions fluid">
        <div class="col-md-offset-3 col-md-9">
            <button type="submit" class="btn blue">Add</button>
            <button type="button" class="btn default">Anuluj</button>                              
        </div>
    </div>
</form>
4

1 回答 1

2

使用 Mopa BootstrapBundle https://github.com/phiamo/MopaBootstrapBundle

在您的控制器中:

 $this->createForm(
      MyFormType(),
      $entity,
      array('attr' => array('class' => 'form-horizontal'))
 );
于 2013-11-13T11:01:57.627 回答