Hi Rohit83,
I usually use Zend_Session to keep form data between requests. I
serialize the post array an keep it in an own session namespace.
Additionally, I pass the form data array to the view in the controller
action, so that the view does not need to know about the existence of
sessions. Take a look at the sample code below.
If everyone has a better idea, I would be happy to know!
Best regards,
Ivan.
/* Display form */
public function displayformAction() {
$this->initView();
// Check session for form data
$formSession = new Zend_Session_Namespace('form');
if (isset($formSession->formData)) {
$formData = unserialize($formSession->formData);
$this->view->formData = $formData;
}
/* Render form */
}
/* Check user input */
public function checkformAction() {
// Get POST data
$request = $this->getRequest();
$post = $request->getPost();
/* Validation logic */
/* If errors, go back to view */
// Pass error message...
$this->view->formData = $post;
// Redirect
/* If input ok */
$formSession = new Zend_Session_Namespace('form');
$formSession->formData = serialize($post);
// Go to previewAction, e.g.
}
Hi All
I have developed a form using zend framework.When i click on submit
button and id if due to validation some error message is displayed , at that
time the values entered in text box will not be retained.
Is their any way to retain these values using zend functionality
Regard,
Rohit83
--
Loglan GmbH
Ivan Ruiz Gallego
Binzmühlestrasse 210
8050 Zürich
Switzerland
Office +41 44 310 19 20
Mobile +41 76 321 23 68
Net www.loglan.net