Is there any w开发者_高级运维ay to set post parameters?
When i submit a form I would like to set a variable (that I give a value dynamically) as a post parameter.
Is that possible?
sf 1.4
Yes and no. It depends what you're actually trying to achieve.
Post parameters in php are stored in the $_POST
super global, which just a global array as far as your php code is concerned. So you could do the following:
$_POST['my_key'] = $value;
This method can also be used to manipulate posted values. But I'd there is a serious issue with you design if you need to add post variables.
I'm not 100% sure what you are asking but if you are using javascript to set a variable then add it as a hidden field which your javascript would set which would then be sent with the form.
If you mean that you want to set give a field a default value then you can do that in the form class
class myForm extends sfForm
{
public function configure()
{
$this->setDefault('fieldName', 5);
}
}
精彩评论