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 7026047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:03:55+00:00 2026-05-28T00:03:55+00:00

I have a Zend form with three select boxes. When the form is first

  • 0

I have a Zend form with three select boxes. When the form is first loaded only the first select box is populated. The user chooses a value from the first box and this populates the second and third boxes.

$element = $this->createElement('select', 'clinicId');
$element->addMultiOption('', ' ');
foreach($this->_clinics as $id => $details)
    $element->addMultiOption($id, $details['clinic_name']);
$element->setAttribs(array('onchange' => 'toggleClinic(this.value, ' . $json . ')'));
$element->setRequired(true);
$element->addErrorMessage('You must select a clinic');
$element->addFilter('StringTrim');
$element->setLabel('Clinic');
$element->clearDecorators();
$element->addDecorator('StandardTable');
if(isset($this->_info['clinic_id']))
    $element->setValue($this->_info['clinic_id']);
$this->addElement($element);
$this->_elementNames[] = 'clinicId';

$element = $this->createElement('select', 'attendeeId');
$element->addMultiOption('', ' ');
$element->setRequired(true);
$element->addErrorMessage('You must select an attendee');
$element->addFilter('StringTrim');
$element->setLabel('Appointment With');
$element->clearDecorators();
$element->addDecorator('StandardTable');
if (empty($this->_info['clinic_id']))
    $element->setAttribs(array('disabled' => true));
else
{
    foreach($this->_clinics[$this->_info['clinic_id']]['physicians'] as $userId => $userName)
        $element->addMultiOption($userId, $userName);
    if(isset($this->_info['provider_id']))
        $element->setValue($this->_info['provider_id']);
}
$this->addElement($element);
$this->_elementNames[] = 'attendeeId';

The third select box is almost identical to the second, just with different labels, variables, etc.

In my javascript toggleClinic() function I have:

$("#attendeeId").removeAttr('disabled');
$("#appointmentType").removeAttr('disabled');
for(id in jsonClinics[selectedId].physicians)
{
    var o = new Option(jsonClinics[selectedId].physicians[id], id); 
    $(o).html(jsonClinics[selectedId].physicians[id]); 
    $("#attendeeId").append(o);
}
for(id in jsonClinics[selectedId].appointment_types)
{
    var o = new Option(jsonClinics[selectedId].appointment_types[id]['name'], id); 
    $(o).html(jsonClinics[selectedId].appointment_types[id]['name']); 
    $("#appointmentType").append(o);
}

This all appears to work. I choose a clinic, and the two other drop downs are correctly populated. I can select items from all three checkboxes, submit the form, and Firebug shows all variables being sent via post. However, in my action in the controller, if ($this->_loader->appointmentform->isValid($request->getPost())) returns false, and the form is redisplayed with errors for the second and third select box. Their values have also been removed so I have to change the selected option of the first select box to retrigger toggleClinic.

Of main concern is the first part, there is obviously something being selected, so why is isValid returning false? Any help would be greatly appreciated.

  • 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-28T00:03:56+00:00Added an answer on May 28, 2026 at 12:03 am

    It was an extremely simple error.

    The way my action worked, the same action was used for creating the form and submitting it, so it had the check to see if the request was a post request after creating the form. I was not passing the submitted value from the first select box to the form, so it was being recreated without anything selected, thus causing the two dynamic select boxes to be unpopulated, causing the error.

    Adding an extra check before creating the form allowed me to send the submitted information back to the form as a parameter, and fixed the problem.

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

Sidebar

Related Questions

I have working user registration form. It consist of Zend Form Elements. Now I
About to create a form using Zend Form, all the form elements should have
I have a form in a Zend-based site which has a required Terms and
I am working on zend. I have a form with some checkboxes. I want
In my project we have a Form where the user either needs to upload
I have a form with a select element that I need to populate with
I have a created a zend form, works fine along with validations. Is there
I have created a form with zend form. I process the data in one
I have a form that is extend from Zend_Form. I am placing the form
I have a Zend form where there are lot of textboxes. I need to

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.