Reputation: 759
I want something like this:
<textarea rows="30" cols="70" class="TextBox" style="height:100px;">
but inside my symfony2 aplication and not in the twig template i tried this:
$builder->add('history', 'textarea', array('label' => 'Nome' , 'max_length' => 1048576 , 'rows' = 30 , 'cols' = 70));
but i get "rows" and "cols" are not options...
in the twig i want something like this:
<label for="history">{{'form_anamnese_history'}}</label>
{{ form_widget(form.history) }}
to be a forum-post-like textbox!
Upvotes: 22
Views: 26612
Reputation: 2194
The solution for problem in Symfony 3
.
First:
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
Second: This is the code in Form:
->add('biografia', TextareaType::class, array(
'label' => 'Como me identifico, Identifiquese utilizando un máximo de 500 caracteres',
'attr' => array('class' => 'myclass')
))
Upvotes: 1
Reputation: 259
You can set the display attributes for textarea in Twig rather than in the form:
{{ form_widget(edit_form.comment, { 'attr': {
'style' : 'width:525px',
'rows' : '4',
'cols' : '30' }} ) }}
As mentioned above, it is better practice to set this in CSS if possible however.
Upvotes: 8
Reputation: 5280
Use the attr
array, as explained in the documentation:
$builder->add('history', 'textarea', array(
'attr' => array('cols' => '5', 'rows' => '5'),
));
Upvotes: 64