views:

32

answers:

2

Hello I want to know if it's possible to add widgets to a CRUD form : I want to select an entry in a list or to enter a text in an input if the entry isn't in list.

The user choose with a radiobutton if he choose in list or write in the input.

It's possible ? If yes, how can I do this ?

A: 

Witjh JQuery you can show/hide content. Then if the radiobutton is "list" the list will be showed and the text field hidden and visceversa.

earlyriser
I know this and it's what I will do. But I don't know how add a radiobutton which doesn't related my model.
Corum
I didn't see your Q was related to Symfony. I don't knwo how it works.
earlyriser
+1  A: 

I'm not entirely sure if I understand your question correctly.

If you want to add fields to your autogenerated forms you can simply modify the "XxxxForm" class which resides in /lib/forms/XxxxForm.class.php. By adding the following code you can add a radio button:

public function configure()
{
  parent::configure();

  $this->widgetSchema['myfield'] = new sfWidgetFormInputCheckbox();
  $this->validatorSchema['myfield'] = new sfValidatorBoolean(array('required' => 'true'));
}

I hope it helps.

phidah
It's exactly what I want, thanks. I didn't know I can do this.
Corum