如何在 Symfony 4 中为表单元素添加样式?
How can I add a style to a form element in Symfony 4?
我正在使用 Symfony 4 中的 formBuilder:
$form = $this->createFormBuilder($item)
->add('username', TextType::class, array('attr' => array('class' => 'form-control')))
我想给表格添加样式:
$form = $this->createFormBuilder($item)
->add('username', TextType::class, array('attr' => array('style' => 'margin-right:5px'), 'attr' => array('class' => 'form-control')))
我没看到样式。它没有添加到字段中...
您有两倍的数组键属性,因此将其更改为:
->add('username', TextType::class, array('attr' => array('class' => 'form-control','style' => 'margin-right:5px')))
我正在使用 Symfony 4 中的 formBuilder:
$form = $this->createFormBuilder($item)
->add('username', TextType::class, array('attr' => array('class' => 'form-control')))
我想给表格添加样式:
$form = $this->createFormBuilder($item)
->add('username', TextType::class, array('attr' => array('style' => 'margin-right:5px'), 'attr' => array('class' => 'form-control')))
我没看到样式。它没有添加到字段中...
您有两倍的数组键属性,因此将其更改为:
->add('username', TextType::class, array('attr' => array('class' => 'form-control','style' => 'margin-right:5px')))