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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:39:22+00:00 2026-05-30T00:39:22+00:00

I have a Zend_Form with a dropdown field. When the user sets a value

  • 0

I have a Zend_Form with a dropdown field.
When the user sets a value in the url this one should be selected as default value in this dropdown.

So what i do at the moment is this:

$parlang = $this->getRequest()->getParam('lang');
if($parlang){
    $this->view->filterForm->getElement('ddLanguage')->setValue($parlang);
}

if ($this->getRequest()->isPost()) {
        if($this->view->filterForm->isValid($_POST)){
...
...
...

No i want to check if the value of the variable is even a valid value for the dropdown? How can i check this in coorporation with the form validation. Yes i can check the variable against a array or so but this seems to be “fighting against the framework”.

So what is the Zend way to do such a thing?

Edit:
My final solution for all who are interested, is:

$parlang = $this->getRequest()->getParam('lang');
if($parlang){
    $ddLanguage = $this->view->filterForm->ddLanguage;
    if($ddLanguage->isValid($parlang)){
        $ddLanguage->setValue($parlang);
        $language = $parlang;
    }
}
  • 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-30T00:39:24+00:00Added an answer on May 30, 2026 at 12:39 am

    I ran a quick test and it looks like one method you can use is Zend_Form_Element_Select::getMultiOption() to check if the language exists in the select values.

    <?php
    
    $parlang = $this->getRequest()->getParam('lang');
    
    if ($parlang) {
        $el = $this->view->filterForm->getElement('ddLanguage');
    
        // attempt to get the option
        // Returns null if no such option exists, otherwise returns a
        // string with the display value for the option
        if ($el->getMultiOption($parlang) !== null) {
            $el->setValue($parlang);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Form element: $Form=new Zend_Form; $Form->setAction($this->view->url(array('controller'=>'auth','action'=>'create'),null,true)) ->setMethod('post') ->setAttrib('id','auth-form') ->removeAttrib('enctype'); As can be
I have a Zend_Form with file element like this: ->addElement('file', 'image', array( 'required' =>
I have created a form like this: class Form_Login extends Zend_Form { public function
I have Login.php form like this: class Form_Login extends Zend_Form { public function init()
I have this in a Zend_Form 's init method: $username_validators = array( 'Alpha', array('StringLength',
I have a Zend application with a Zend_Form, which should use the HTML5 placeholder
Here I have a password field: /*********************PASSWORD**********************/ $password = new Zend_Form_Element_Password('password'); $alnumValidator = new
About to create a form using Zend Form, all the form elements should have
I have Zend_Form empty values problem: My View: I print only part of form
i have created my own Zend_Form class currently just to add some helper functions

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.