Reputation: 3323
Maybe I am missing something, but in symfony examples, in form submission action there's nothing which indicates form data is saved to database. (link). How can I save everything to db?
Example from the link:
public function executeSubmit($request)
{
$this->forward404Unless($request->isMethod('post'));
$params = array(
'name' => $request->getParameter('name'),
'email' => $request->getParameter('email'),
'message' => $request->getParameter('message'),
);
$this->redirect('contact/thankyou?'.http_build_query($params));
}
Upvotes: 0
Views: 5311
Reputation: 27102
If you have a form that's based on a model (eg Doctrine or Propel object), you'll need to do something like the following in your action:
$this->form = new MyForm();
$this->form->bind($params);
if ($this->form->isValid())
{
$this->form->save();
}
These seem to be the crucial steps that you're missing. As others have pointed out, the Symfony tutorials provide good examples of this.
Upvotes: 1
Reputation: 11382
As well as VolkerK's link, the jobeet tutorial covers doctrine (or propel if you prefer that as your ORM) forms.
http://www.symfony-project.org/jobeet/1_4/Doctrine/en/10
Upvotes: 0
Reputation: 96159
Take a look at http://www.symfony-project.org/forms/1_4/en/04-Propel-Integration:
In a Web project, most forms are used to create or modify model objects. These objects are usually serialized in a database thanks to an ORM. Symfony's form system offers an additional layer for interfacing with Propel, symfony's built-in ORM, making the implementation of forms based on these model objects easier.
Upvotes: 0