This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » legacy support » symfony 1.1 » Modify form widgetSchema in action
icon5.gif  Modify form widgetSchema in action [message #64280] Fri, 31 October 2008 09:49 Go to next message
Monti  is currently offline Monti
Messages: 14
Registered: April 2008
Location: Germany
Junior Member
Hi there,

I am trying to modify a form widgetSchema in the action.

I am using a sfWidgetFormPropelSelect widget and the content of the dropdown should be depending on the page.

So, in the Action, I'd like to change/modify/recreate the criteria that is being used for the widget, depending on the id of the item we are showing.

Is there a way to change the exisiting sfWidgetFormPropelSelect or maybe unset the existing and add a new widget in the action?

I was searching the web, the forum and the API but I could net get it going. Is there no method to access/modify the widgetSchema in the action?

Thanks a lot

Re: Modify form widgetSchema in action [message #64290 is a reply to message #64280 ] Fri, 31 October 2008 11:00 Go to previous messageGo to next message
joostdj  is currently offline joostdj
Messages: 44
Registered: November 2007
Member
You can access the widgetSchema from your action:

$form->getWidgetSchema()
Re: Modify form widgetSchema in action [message #64369 is a reply to message #64290 ] Sat, 01 November 2008 19:41 Go to previous messageGo to next message
Monti  is currently offline Monti
Messages: 14
Registered: April 2008
Location: Germany
Junior Member
Hi,

thanks for the reply.

Unfortunately, it seems I could not really describe the problem.

Of course I found out I can access $form->getWidgetSchema()

However, it seems manipulation of the widget schema is only possible in the forms configure method, not in the action (it's protected)

So, to maybe make my problem clear, let's just assume the following:


There is a form, defined in lib/forms/myForm that contains a sfWidgetFormSelect with options "A" and "B".

Now, in the action, I'd simply like to add another option, namely

$this->getRequestParameter('id');

to the dropdown.


So, again the question:

How can I do that?

Is there no method to modify the widgetSchema in the action?

Thanks

Peter
Re: Modify form widgetSchema in action [message #64387 is a reply to message #64280 ] Sun, 02 November 2008 10:35 Go to previous messageGo to next message
joostdj  is currently offline joostdj
Messages: 44
Registered: November 2007
Member
Check the following forum post for 2 possible solutions:

http://www.symfony-project.org/forum/index.php/m/56588/
Re: Modify form widgetSchema in action [message #64404 is a reply to message #64387 ] Sun, 02 November 2008 17:09 Go to previous messageGo to next message
Monti  is currently offline Monti
Messages: 14
Registered: April 2008
Location: Germany
Junior Member

Thanks a lot!

That's more what I was hoping to get and it solved my issue.

After playing with the solution, I just noticed one thing:

This really only works for forms that extend sfForm

Auto-generated forms extend sfFormPropel (in my case) and they do not accept default values as parameter.

Re: Modify form widgetSchema in action [message #64406 is a reply to message #64280 ] Sun, 02 November 2008 18:10 Go to previous messageGo to next message
joostdj  is currently offline joostdj
Messages: 44
Registered: November 2007
Member
I just tested something and this should work from an action:

$widgetSchema = $form->getWidgetSchema();
$widgetSchema['fieldname']->setOption('choices' => array('value 1', 'value 2'));
Re: Modify form widgetSchema in action [message #90279 is a reply to message #64406 ] Mon, 21 December 2009 01:27 Go to previous message
pachinsv  is currently offline pachinsv
Messages: 7
Registered: December 2009
Junior Member
Muchas gracias joostdj, a mi me funciono perfectamente.

Previous Topic:Symfony 1.2 doctrain (Check box issue)
Next Topic:sfSmartyView problem
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software