Hi Xavier

Are you also using the MVC component? I highly recommend you leave the redirection of actions to the dispatcher and the form to do the processing. I'm not a huge fan of creating sessions for form data unless they really do need to be session-aware (like multi-page forms, etc). You can get around the double-submission simply by utilising HTTP requests.

public function enquiryAction()
{
    $form = new My_Enquiry_Form();
    // do stuff...

    $request = $this->getRequest();

    if ($request->isPost() && $form->isValid($request->getPost()) {
        // do stuff with form values...
        $this->_helper->redirector('thankyou');
    }

    $this->view->form = $form;
}

public function thankyouAction()
{
    // Write out thankyou script
}

No javascript required :)

Great work with ZF 1.5 !!

By the way, i've started to experiment with Zend_Form and I find it more intuitive than his counterpart (Pear Quickform) to me. But one thing i would like to have in a near future, is the ability to implement the Post-Redirect-Get pattern with Zend_Form.

Now, with Zend_Form you can POST to the same action or to another one, but the problem arises when someone hits the "reload" button in his browser, showing the nasty "Caution: you are about to send a form again...bla bla..." message.

May be could be a good idea to implement a Session container and save the form data into, using a special ID for each form. So, if the action processing the form sees is not valid can make a 'redirect' and the Form Component can redraw the form with session data, validation errors, etc....

Yes, i know it's not a major issue, but i hate the 'double submit' message. Now i'm working with Ajax and encrypted tokens to avoid double submits (accidental or not), but i don't want to rely always on javascript.


--

Simon Mundy | Director | PEPTOLAB

""" " "" """""" "" "" """"""" " "" """"" " """"" "  """""" "" "

202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000
Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654 4124
http://www.peptolab.com

Reply via email to