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 » support » symfony 1.3 and 1.4 » For one model, many forms if different updates ?
icon5.gif  For one model, many forms if different updates ? [message #103271] Fri, 30 July 2010 09:30 Go to next message
coelho.ric  is currently offline coelho.ric
Messages: 4
Registered: July 2010
Junior Member
Hi,

First, sorry for my english.

I'm new on symfony, i need advices.

Imagine a model with 5 inputs (I1 to I5).

Example 1 :
While I5 is empty, I can update I1 to I3.
Otherwise, I can only update I4.
NB : I5 isn't updated with the form.

Example 2 :
User with permission A can update I1 to I3
User with permission B can update I3 to I4.
User with permission C can update I5.
...etc...
So, user with permissions A et B can update I1 to I4.

What is the best pratice ?
Can I do everything with one form ? But how ?
Or have I to make one form per possibility (for ex1 : one form I5 empty, one form for I5 not empty) ?

Thks in advance

[Updated on: Fri, 30 July 2010 09:39]

Re: For one model, many forms if different updates ? [message #103282 is a reply to message #103271 ] Fri, 30 July 2010 11:36 Go to previous messageGo to next message
xplo  is currently offline xplo
Messages: 428
Registered: September 2008
Faithful Member
you can do it with 1 form if you use the option parameter :

//action
$this->form = new Form(null, array('permission' => 'A'));

//configure
$permission = $this->getOption('A');
icon9.gif  Re: For one model, many forms if different updates ? [message #103297 is a reply to message #103282 ] Fri, 30 July 2010 14:00 Go to previous messageGo to next message
coelho.ric  is currently offline coelho.ric
Messages: 4
Registered: July 2010
Junior Member
... and ?

If I have permission B, how to have I1, I2 and I5 in "readonly mode" (text) ?
In that case, I would like that "$form['I1']" became a label, not input.
Re: For one model, many forms if different updates ? [message #103298 is a reply to message #103297 ] Fri, 30 July 2010 14:09 Go to previous messageGo to next message
xplo  is currently offline xplo
Messages: 428
Registered: September 2008
Faithful Member
usefield method can be pretty useful for write only is you use a propel/doctrine form.

i usually try to avoid html read only field since you dont get the value after a submit and hence have to avoid deleting data.
Re: For one model, many forms if different updates ? [message #103300 is a reply to message #103271 ] Fri, 30 July 2010 14:23 Go to previous messageGo to next message
coelho.ric  is currently offline coelho.ric
Messages: 4
Registered: July 2010
Junior Member
So you don't use the renderXXX methods of a form ?
do you only display like that :

<?php echo $form?>

?
Re: For one model, many forms if different updates ? [message #103303 is a reply to message #103300 ] Fri, 30 July 2010 14:41 Go to previous messageGo to next message
xplo  is currently offline xplo
Messages: 428
Registered: September 2008
Faithful Member
Depends of what i need, if i can get away with echo $form i do it Smile

for you case i would create method in the form that would be called in the template to know what to display and in form to know what you save if you want to customize your form template.
Re: For one model, many forms if different updates ? [message #103304 is a reply to message #103303 ] Fri, 30 July 2010 14:44 Go to previous message
coelho.ric  is currently offline coelho.ric
Messages: 4
Registered: July 2010
Junior Member
Ok, so, there is no "Symfony standard solution" in my case, isn't ?
Previous Topic:[SOLVED] Variables accessible from every modules action and template
Next Topic:createing embeded form
Goto Forum:
  

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