0

How to put space in between option value of Zend_Form_Element_Select Expected result as follows,

http://jsfiddle.net/HLbQE/

Tried as follows,

$this->addElement('Select', 'parent_id', array(
      'label' => 'Select Category',
      'multiOptions' => array('0'=>'Gents','1'=>'   Jeans','2'=>'   Sunglass','3'=>'Ladies','4'=>'   Jeans','5'=>'   Sunglass')
));

but fails,

Any help please

2 Answers 2

2

Why not just use optgroups? ZF handles this natively by using a nested array for the multi-options, eg

$options = array(
    'Gents' => array(
        1 => 'Jeans',
        2 => 'Sunglass'
    ),
    'Ladies' => array(
        3 => 'Jeans',
        4 => 'Sunglass'
    )
);

Updated demo here - http://jsfiddle.net/HLbQE/1/

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

3 Comments

+1 That might be an even better solution in this case indeed.
here how can i select gents or ladies? :-(
@Kyathi do you actually need to? Unless you write your own view helper, I think you're out of luck
0

Try this:

$this->addElement('Select', 'parent_id', array(
      'label' => 'Select Category',
      'multiOptions' => array('0'=>'Gents','1'=>'   Jeans','2'=>'   Sunglass','3'=>'Ladies','4'=>'   Jeans','5'=>'   Sunglass'),
      'escape' => false // <-- added 
));

I seems this will not work indeed, as reported in this, still unresolved, issue:
http://framework.zend.com/issues/browse/ZF-5351

2 Comments

@Kyathi: what is the output you are getting?
it will print &nbsp;&nbsp;&nbsp;Jeans in option value

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.