Php zend form多复选框命名
我必须如何嵌套多复选框,以便它们的名称类似于“foo[]['bar']” 我使用过子表单,但它们给我的命名是这样的“foo[bar][]” 我的代码: $sub=新的Zend_表单_子表单(“sub”) $wish=新Zend_Form_Element_MultiCheckbox('bar') $wishPhp zend form多复选框命名,php,zend-framework,Php,Zend Framework,我必须如何嵌套多复选框,以便它们的名称类似于“foo[]['bar']” 我使用过子表单,但它们给我的命名是这样的“foo[bar][]” 我的代码: $sub=新的Zend_表单_子表单(“sub”) $wish=新Zend_Form_Element_MultiCheckbox('bar') $wish ->setMultiOptions($education_direction->getAll()) ->setLabel('Wish') ->setRequir
->setMultiOptions($education_direction->getAll())
->setLabel('Wish')
->setRequired(true);
$sub->addElements(数组)(
$wish
));
$this->addSubForm($sub,'foo')
我认为您正在为Zend表单元素寻找“belongsTo”选项 如果你需要一些东西,比如: 尝试:
令人惊叹的。我已经设置了'belongsTo'=>'foo[],并且我得到的字段名是'foo[]['field1]'。工作起来很有魅力。非常感谢:)
$this->addElement(
'text', 'field1',
array(
'label' => 'field',
'belongsTo' => 'foo'
));