In Symfony Form class get the value of submitted fields
In symfony how I will get the value of $_REQUEST in a form class. I am getting the value of all form fields in action.class.php and templates. While submitting a form and it is valid开发者_如何学JAVAating I need to get the value of some form field. Please help me!
If you want a value from a form after it's been bound and validated etc:
$value = $myForm->getValue("field_name");
If you want it before you pass it to the form:
public function executeMyAction(sfWebRequest $request)
{
$myForm = new MyForm();
$allFormValues = $request->getParameter($myForm->getName());
$value = $allFormValues["field_name"];
// usual form stuff follows eg:
$myForm->bind($allFormValues);
// ...
}
If you want it eg in a postvalidator method in your form's validation schema:
public function myPostValidate($validator, $values)
{
$myValue = $values["field_name"];
// ...
return $values;
}
Anything else, please expand your question and provide more detail as to what you're trying to do :-)
How about using this?:
sfContext::getInstance()->getUser()->getAttribute('your_widget_field_name');
精彩评论