0
votes

I would like to change my input class (type text) to a Bootstrap 3 class, whithin the admin generator.

I tried to change the values within the BaseyyyyFormFilter.php and achievied it but it doesn't seem right to do this. I also changed with a foreach within the yyyyFormFilter which extends the previoius one, however it was done with

foreach ($this->getWidgetSchema()->getFields() as $field)
{
     $field->setAttribute('class', 'someclass');
}

However this doesn't seem quite right as it changes all my input classes despite it's input type. Doesn't symfony have something to do this already? I'm pretty sure there must be a way I'm missing.

Thanks in advance.

2

2 Answers

0
votes

Your code seems fine but this foreach will changes all your widgets style class to someclass

You just need to add this line before setAttribute see below:

if ($field instanceof sfWidgetFormInputText)
    $field->setAttribute('class', 'someclass');
0
votes

If anyone wants to do this, the solution I found was to do the following:

$this->getWidget('name')->setAttribute('class','some_class');

Thanks to Haithem however!