ZF-2824: There is a serious need to change how Zend_Form handles populating multioption elements when creating form from config


In current implementation when creating lets say SELECT element, we need to pass the options as 'val'=>'text', with that approache we face a problem when we want to assign integer value to option. With current zend_config we would need to have in XML something like <1>type11>, this is illegal in xml - so we cant assign integer values to options, and i think that is the most common use case for select elements ( database normalization for inserting values etc. ).

I would suggest we have something that could accept a format like

array(1) {
  array(3) {
    array(2) {
      string(1) "1"
      string(2) "aa"
    array(2) {
      string(1) "2"
      string(4) "xxxx"
    array(2) {
      string(3) "444"
      string(4) "ssss"

That way we can store our configuration in XML and generate options with text values as well.


Resolved in trunk and release-1.5 branch. You can now specify formats like the following in your config files:

  • INI

options.first.key = "aa"
options.first.value = 1
options.second.value = "xxxx"
options.second.key = 2
options.third.key = "ssss"
options.third.value = 444
  • XML

<?xml version="1.0"?>
  • PHP:

$options = array(
        'value' => '1',
        'key'   => 'aa',
    array (
        'key'   => '2',
        'value' => 'xxxx',
    array (
        'value' => '444',
        'key'   => 'ssss',

I would suggest reopening this issue for the following reason: Short-hand xml configuration does not work.


Generates this (formatted for readability):