我的zend形式有一个名为select的公共函数,其中它包含了元素和元素选择以添加addmultioptions,每个addmultioption都有一个特定的形式,在选择后出现,一些形式虽然由一个datepickers组成,但我有选择带有datepickers的那些选择字段时出现问题。请记住我正在使用Jquery,并在我的application.ini中包含了Zendx长度,并尝试扩展ZendX_JQuery_Form类。
我有一些使用相同方法的日期选择器的表单,但不确定这个是什么。下面是我的代码。
下面是我的代码的例子。
<?php
class Form_Excel extends ZendX_JQuery_Form //Tried Both methods normally use the one below
class Form_Excel extends Zend_Form
{
public function init()
{
}
public function excel()
{
$type = new Zend_Form_Element_Select('type');
$type->setLabel('Select a Type:')
->addMultiOption('1', ' Report1')
->addMultiOption('2', ' Report2')
->addMultiOption('3', ' Report3')
->addMultiOption('4', ' Report4')
->addMultiOption('5', ' Export5')
->addMultiOption('6', ' Report6')
->addMultiOption('7', ' Report7')
->addmultiOption('8', ' Report8');
$type->addDecorator(array('row' => 'HtmlTag'), array('tag' => 'div','class' => 'col-md-12 field-box','style' => 'padding-left:0;padding-top:10px;margin-bottom: -35px;clear: both;'))
->addDecorators(array(array('HtmlTag',array('tag' => 'dd', 'class' => 'ui-custom search-width span5'))));
$this->addElement($type);
}
public function 1()
{
$hidden = new Zend_Form_Element_Hidden('hidden');
$hidden->setValue('status');
$this->addElement($hidden);
$status = new Zend_Form_Element_Select('status');
$status->setLabel('Current Status: ')
->addMultiOption('', '--Select One--')
->addMultiOption(1, 'First')
->addMultiOption(2, 'Second')
->addMultiOption(3, 'Contacted')
->addDecorator(array('row' => 'HtmlTag'), array('tag' => 'div','class' => 'col-md-12 field-box','style' => 'padding-left:0;padding-top:10px;clear: both;'));
$status->setAttribs(array('class' => 'col-md-12 form-control'));
$this->addElement($status);
//Assessed Before / After
$before = new ZendX_JQuery_Form_Element_DatePicker('before');
$before ->setLabel('Date Before: ')
->addFilter('StripTags');
$before ->setJQueryParams(array(
'dateFormat'=>'yy-mm-dd',
'changeMonth'=> true,
'changeYear'=> true
))
->addDecorator(array('row' => 'HtmlTag'), array('tag' => 'div','class' => 'col-md-4 field-box the-font print-container','style' => 'padding-left:0;padding-top:10px;'));
$before->setAttribs(array('class' => 'col-md-4 form-control the-font text-field'));
$this->addElement($before);
$after = new ZendX_JQuery_Form_Element_DatePicker('after');
$after ->setLabel('Date After: ')
->addFilter('StripTags');
$after ->setJQueryParams(array(
'defaultDate' => date('d-m-y'),
'changeMonth'=> true,
'changeYear'=> true
))
->addDecorator(array('row' => 'HtmlTag'), array('tag' => 'div','class' => 'col-md-4 field-box the-font print-container','style' => 'padding-left:0;padding-top:10px;'));
$after->setAttribs(array('class' => 'col-md-4 form-control the-font text-field'));
$this->addElement($after);
$submit = new Zend_Form_Element_Submit('submit');
$submit ->setLabel('Submit')
->setAttrib('class', 'btn-flat primary')
->addDecorator(array('row' => 'HtmlTag'), array('tag' => 'div','style' => 'width: 88%; padding-left:0;clear: both;'));
$this->addElement($submit);
}
}
答案 0 :(得分:0)
使用时:
$this->view->form = new Form_Excel();
通常只执行表单的init()
方法。
要执行另一个方法,我们仍然会实例化该类,然后调用一个方法。
例如
$this->view->form->excel();
然后在视图中:
<?= $this->form ?>
将返回select
元素。