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

  • SEARCH
  • Home
  • 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 8762123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:27:06+00:00 2026-06-13T15:27:06+00:00

I have two dropdown in a form for selecting department and designation. $model =

  • 0

I have two dropdown in a form for selecting department and designation.

$model = new Application_Model_DbTable_Department();
$departments = $model->fetchAll();
$department = $this->createElement('select','department');
$department->setLabel('Department');
$department->setAttrib('class', 'department');
foreach($departments as $d)
    $department->addMultiOption($d->id, $d->depname);

$model = new Application_Model_DbTable_Designation();
$designations = $model->fetchAll('depid=1');
$designation = $this->createElement('select','designation');
$designation->setLabel('Designation');
$designation->setAttrib('class', 'designation');
$designation->setRegisterInArrayValidator(false);
foreach($designations as $ds)
    $designation->addMultiOption($ds->id, $ds->designation);

I have jquery function to for designation lookup when onchange of department. My problem is when submitting the form if the form has validation error , I need to display the selected designation.

  • 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-06-13T15:27:07+00:00Added an answer on June 13, 2026 at 3:27 pm

    In cases like this, It is best to do the form population after the form has been instantiated. Reason: it is next to impossible to get the values of the form elements on initialization because they do not exist yet (That is, in the init() method of the Zend_Form). You could do this:

    $form = new Your_Zend_Form();
    $designation = $form->getElement('designation');
    
    $departmentId = null;
    
    $request = $this->getRequest();
    
    if($request->isPost()){
        $departmentId = $request->getPost('department');
    }
    
    $desigantionOptions = $this->_getDesignationOptions($departmentId);
    
    $designation->addMultiOptions($desigantionOptions);
    

    This would be in your controller action or something… But in essence, your designation options would take values from the current department if available from the post or else it would fall to the default selection. The method signature of $this->_getDesignationOptions($departmentId) will be as follows:

    protected function _getDesignationOptions($departmentId = null);
    

    And this would return an array of value/option pair.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have two dropdown list. first drop down:1 enter code here <form:select path=custName id=custName>
I am using Asp.net dropdownlist in one of my form ..I have two dropdown
I have a form with two text boxes, one select drop down and one
I have two dropdowns in extjs,based on the first dropdwon,the second dropdown populates.This is
I have a form where there are two dropdown lists that are populated from
I have a form that has a datePicker and two dropdown boxes for the
I have two forms here, the first is a select dropdown select, which when
I have a simple PHP script with a form that has two select fields,
I have two dropdown ddlCountry and ddlState and one button Submit. While ddlstate is
Hi I have two dropdown menus: priceMaximum and mortgageMaximum I want it so if

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.