Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6881397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:06:08+00:00 2026-05-27T05:06:08+00:00

class Application_Form_ImageUpload extends Zend_Form { protected $user_id; function __construct($id){ $this->user_id = $id; } public

  • 0
class Application_Form_ImageUpload extends Zend_Form
{
    protected $user_id;

    function __construct($id){
            $this->user_id  = $id;
    }
    public function init()
    {
        $user_path = '/var/www/upload/' . $this->user_id;
    ...
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Upload');

        $this->addElement($element, 'image');
        $this->addElement($submit, 'submit');
    }



}

Calling:

        $email = Zend_Auth::getInstance()->getIdentity();
    $user_id = $mapper->getUserId($email);
    $uploadForm = new Application_Form_UserImageUpload($user_id);

After adding the constructor, the output for the form becomes blank. Why is that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:06:08+00:00Added an answer on May 27, 2026 at 5:06 am

    Because you’ve overridden the default ZF constructor which calls init

    /**
     * Constructor
     *
     * Registers form view helper as decorator
     *
     * @param mixed $options
     * @return void
     */
    public function __construct($options = null)
    {
        if (is_array($options)) {
            $this->setOptions($options);
        } elseif ($options instanceof Zend_Config) {
            $this->setConfig($options);
        }
    
        // Extensions...
        $this->init();
    
        $this->loadDefaultDecorators();
    }
    

    You can solve it by calling it in yours:

    function __construct($id){
      $this->user_id  = $id;
      parent::__construct();
    }
    

    Or if you want a more generic solution, Zend_Form default constructor calls its setOptions method which uses magic methods to set properties, so if you write a setter in your form class it will be called with options values. Example:

    // in your class
    class My_Form extends Zend_Form {
      protected $_uid;
    
      public function setUid($uid) {
        $this->_uid = $uid;
      }
    
      public function getUid() {
        return $this->_uid;
      }
    }
    // build the form
    $form = new My_Form(array('uid' => 123)); // this calls setUid automagically
    echo $form->getUid(); // outputs 123
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following class for a form: class Application_Form_ContactForm extends Zend_Form { public function
This is my screen: final class GeneralExpenseViewScreen extends MainScreen { public GeneralExpenseViewScreen() { super();
If I have the following simplistic form: <?php class Application_Form_Contact extends Zend_Form { public
I'm using Zend_Form for an application form using this code: class Form_ApplicationForm extends Zend_Form
I have code similar to this in my application: class A { public: int
Zend Form is not my friend today! This works :- Controller:- public function indexAction()
I have a class Application that my global.asax inherits from. The class has this
i have an application class inherited from QtGui.QDialog. I have to reload show-function but
I'm perplexed by this. I have a login action that looks like this: public
What I want to do is access the query function in my database class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.