tirenweb
tirenweb

Reputation: 31709

Symfony 1.2: question about a line in an action

this action is generated in symfony 1.2 when you create a module:

public function executeUpdate(sfWebRequest $request) {
    $this->forward404Unless($request->isMethod('post') || $request->isMethod('put'));
    $this->forward404Unless($usuario = Doctrine::getTable('Usuario')->find(array($request->getParameter('id'))), sprintf('Object usuario does not exist (%s).', $request->getParameter('id')));
    $this->form = new UsuarioForm($usuario);

    $this->processForm($request, $this->form);

    $this->setTemplate('edit');
}

Can some explain the line?:

$this->forward404Unless($request->isMethod('post') || $request->isMethod('put'));

I don't know the reason why it is there.

Regards

Javi

Upvotes: 0

Views: 113

Answers (1)

Amy B
Amy B

Reputation: 17977

The line says if the user just clicked "submit" on the form and a POST request was made.

Without it, people can browse to that action without sending any data.

I would recommend you remove the || $request->isMethod('put') part though -- nobody uses PUT.

Upvotes: 1

Related Questions