I can’t seem to get the inputted text of a textarea. When I do :
die($request->getPostParameter('comment'))
It outputs the word “array”. When I print_r() it does show the textarea is an array and its value is stored in the array. But I don’t know how to get that value so I can put it into a field in a table.
@greg0ire: I am doing this because I am trying to save data to two different tables. My html page displays a form that is actually made up of two forms from two different classes/models. I have managed to save all fields to both tables except for the comment field. I then tried getting the value and realising it was an array, wondered if this was what was causing my data not to save. This is why I am asking this question. I have asked another question which explains the context.
These are the functions that run on clicking the submit button
public function executeUpdateInlineForm(sfWebRequest $request)
{
$overdueInvestigation = Doctrine_Core::getTable('investigation')->find( $request->getParameter('id'));
$investigationForm = new investigationInlineForm($overdueInvestigation);
$commentForm=new commentForm();
$investigationForm->bind($request->getParameter($investigationForm->getName()), $request->getFiles($investigationForm->getName()));
$commentForm->bind($request->getParameter($commentForm->getName()), $request->getFiles($commentForm->getName()));
$this->processInlineForm($investigationForm, $commentForm);
}
protected function processInlineForm(sfForm $investigationForm, sfForm $commentForm)
{
if ($investigationForm->isValid())
{
$investigation = $investigationForm->save();
$comment = $commentForm->updateObject();
$comment->setInvestigation_id($investigationForm->getObject()->getId());
$comment->setComment($commentForm->getObject()->getComment());
$comment->setuserId($investigationForm->getObject()->getCreatedUserId());
$comment->setDateEntered(time());
$comment->save();
$this->redirect('investigation/overdue/');
}
}
you could simply store
$request->getPostParameter('comment')in an array and usearray_pop()on this array, but I think it would be better to understand why you’re getting an array. I think the name of the textarea must becomment[], when it should probably be justcomment.UPDATE
After reading your update and your other question it seems you need to have this naming convention for your fields:
Use the
setNameFormat()method on the widget schema of your forms to achieve this, then bind your investigation form to theinvestigationrequest parameter, and your comment form to thecommentparameter and you will be fine.Good luck!