【发布时间】:2012-02-02 19:19:19
【问题描述】:
我正在使用 zend 框架表单, 我是 zend 框架的新手,我想像这样显示我的复选框表单:-
*SK336
*CP
*PES
*JCP
*BGH
*SK996
*KO
*RTY
*HGR
*SK547
*GPK
*SK478
*JUP
注意 :- * 是这里的复选框
我在这里尝试的是:-
public function init()
{
$parents = array();
$childs = array();
foreach ($this->Tagkey as $aResultDataValue) {
$parents [$aResultDataValue['parent']] = $aResultDataValue['parent'];
$childs [$aResultDataValue['parent']][] = $aResultDataValue['child'];
}
foreach ($parents as $parent){ // print_r ($parents); die();
$tags = new Zend_Form_SubForm();
$tags->addElements(array(
new Zend_Form_Element_MultiCheckbox('parent', array(
'multiOptions' => array($parent),
'filters' => array('StringTrim'),
'validators' => array(
array('InArray',
false,
array($parent))
)
)),
));
foreach ($childs as $child){
$tags->addElements(array(
new Zend_Form_Element_MultiCheckbox('child', array(
'multiOptions' => array($child),
'filters' => array('StringTrim'),
'validators' => array(
array('InArray',
false,
$child)
)
)),
));
}
$this->addSubForms(array(
'tags' => $tags,
)
);
}
我可以在任何.php 页面中创建这种类型的结构,但现在不能以 zend 框架形式创建,我在这里使用 zend 子形式。
当我使用这个查询时,我现在也遇到了一个错误
警告:htmlspecialchars() 期望参数 1 为字符串,数组在 /var/www/dashboard_campaign/library/Zend/View/Abstract.php 第 905 行给出
More Information关于我的问题:-
(1) mysql qyery
select b.tagCode parent,a.tagCode child from tag a, tag b where a.tagParentId=b.tagId
(2) Zend_Debug::dump($this->Tagkey) 的输出;
array(9) {
[0] => array(2) {
["parent"] => string(5) "SK336"
["child"] => string(2) "CP"
}
[1] => array(2) {
["parent"] => string(5) "SK336"
["child"] => string(3) "PES"
}
[2] => array(2) {
["parent"] => string(5) "SK336"
["child"] => string(3) "JCP"
}
[3] => array(2) {
["parent"] => string(5) "SK996"
["child"] => string(2) "KO"
}
[4] => array(2) {
["parent"] => string(5) "SK996"
["child"] => string(3) "RTY"
}
[5] => array(2) {
["parent"] => string(5) "SK996"
["child"] => string(3) "HGR"
}
[6] => array(2) {
["parent"] => string(5) "SK547"
["child"] => string(3) "GPK"
}
[7] => array(2) {
["parent"] => string(5) "SK478"
["child"] => string(3) "JUP"
}
[8] => array(2) {
["parent"] => string(5) "SK336"
["child"] => string(3) "BGH"
}
}
【问题讨论】:
-
您可能需要自己构建它。我在 ZF 没见过这样的东西。
标签: php zend-framework