How to change selectbox into textbox in symfony 1.2 framework?

205 Views Asked by At

I am new to the symfony framework. I've worked on an already existing project so I want change a selectbox into a textbox using symfony 1.2.

1

There are 1 best solutions below

0
Martin Lyne On

Some more information and code snippets would have helped but..

There are several places this could be achieved, I will go for the 2 most direct and hopefully, common.

1) Your form has already been customised and will likely live in plugins/yourPlugin/lib/form/yourForm.class.php

In here there will be something like $this->setWidget('my_input', new sfWidgetChoice(array([...])));

There are many "Choice" widgets it may be (Doctrine or Propel if they come from the database)

You will need to change it to $this->setWidget('my_input', new sfWidgetFormInput());

2) Your form has not been modified before and is the generated form

You will need to go into your actions.class.php (or components.class.php) and find where it says $this->form = new yourForm();

Make a new form in plugins/yourPlugin/lib/form and make it extend your previous form.

class yourNewForm extends yourForm

Then add

public function setup()
{
 $this->setWidget('my_input', new sfWidgetFormInput());
}

You will likely have to update the validator as well, or it will be expecting data in the "selct box" format.

http://www.symfony-project.org/api/1_1/sfWidgetFormInput