symfony: trying to set a field inside executeUpdate()
I have just generated a module and I'm trying to set the value of a field before saving it this way:
public function executeUpdate(sfWebRequest $request)
{
$this->process = $this->getRoute()->getObje开发者_开发问答ct();
$this->form = $this->configuration->getForm($this->process);
$this->form['user_process_list'] = array(1,2); //this is my code
but I'm getting this error:
"Cannot update form fields."
So, how can I set it?
Exception with "Cannot update form fields." message is thrown while trying to access form field which doesn't exist.
Anyway, the right place for updating form values is in the form itself. You can update value of any field with updateXXXColumn() method (where XXX is a PHP name of the column):
public function updateUserProcessListColumn($value)
{
return array(1, 2);
}
Of course the field needs to exist in the form and appropriate column in your model as well.
精彩评论