Posted by Jeremy Kendall on Wed 21 Jan 12:29
report abuse | download | new post
- <?php
- /**
- * FormsController
- *
- * @author Jeremy Kendall <jeremy@jeremykendall.net>
- */
- require_once 'Zend/Controller/Action.php';
- class FormsController extends Zend_Controller_Action {
- /**
- * The default action - show the home page
- */
- public function indexAction() {
- // TODO Auto-generated FormsController::indexAction() default action
- }
- /**
- * Shows the dynamic form demonstration page
- */
- public function dynamicFormElementsAction() {
- $form = new Code_Form_Dynamic();
- // Form has not been submitted - pass to view and return
- if (!$this->getRequest()->isPost()) {
- $this->view->form = $form;
- return;
- }
- // Form has been submitted - run data through preValidation()
- $form->preValidation($_POST);
- // If the form doesn't validate, pass to view and return
- if (!$form->isValid($_POST)) {
- $this->view->form = $form;
- return;
- }
- // Form is valid
- $this->view->form = $form;
- }
- /**
- * Ajax action that returns the dynamic form field
- */
- public function newfieldAction() {
- $ajaxContext = $this->_helper->getHelper('AjaxContext');
- $ajaxContext->addActionContext('newfield', 'html')->initContext();
- $id = $this->_getParam('id', null);
- $element = new Zend_Form_Element_Text("newName$id");
- $element->setRequired(true)->setLabel('Name');
- $this->view->field = $element->__toString();
- }
- }
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.