0

Please check the code below, the problem is that no form element are displayed in test action not able to locate

Test.php-->Form Class

class Application_Form_Test extends Zend_Form
    {
        public $T_FILEUP;
        public $T_SUBMIT;
        /*function init 
         * initialise all the elements
         * */
        public function _init()
        {
            $this->T_FILEUP=new Zend_Form_Element_Text('image');
            //$this->T_FILEUP->setDestination(UPLOADS);

            $this->T_SUBMIT=new Zend_Form_Element_Submit('add');



        }
        /*function to generate a form for specific function
         * */
        public function generateForm()
        {
            return $this->addElements(array($this->T_FILEUP,$this->T_SUBMIT));
        }

    }

TestAction

public function testAction()
    {
        $objForm=new Application_Form_Test();
        $forms=$objForm->generateForm();
        $this->view->form=$forms;
  }

test.phtml

<?php 
//echo $this->nm;
echo $this->form->image;
?>

3 Answers 3

2

The function name for the hook is wrong (no "_"):

use:

        public function init()
        {
            $this->T_FILEUP=new Zend_Form_Element_Text('image');
            //$this->T_FILEUP->setDestination(UPLOADS);

            $this->T_SUBMIT=new Zend_Form_Element_Submit('add');     

        }
Sign up to request clarification or add additional context in comments.

Comments

1

It is not generated because _init() method is not exectuted. I believe that you wanted to use init() rather that _init().

Comments

0

Just to clarify because I've had this same issue.

Bootstrap.php
_initXXXXX()

Controllers and Forms
init()

Subtle difference, but it will cause you to bang your head on a wall if you don't catch it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.