本文整理汇总了PHP中Zend_Form::setDecorators方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form::setDecorators方法的具体用法?PHP Zend_Form::setDecorators怎么用?PHP Zend_Form::setDecorators使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form
的用法示例。
在下文中一共展示了Zend_Form::setDecorators方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getForm
public function getForm()
{
$form = new Zend_Form();
$form->setMethod('post');
$form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report4Form.phtml'))));
$items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT_PLAN_YEAR');
$e = new Zend_Form_Element_Select('period', array('label' => 'Період', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 80px'));
$form->addElement($e);
$items = $this->getGuideItems('T_EDUFORM', false);
$e = new Zend_Form_Element_Select('eduform', array('label' => 'Форма навчання', 'multiOptions' => $items, 'style' => 'width: 200px'));
$form->addElement($e);
$items = $this->getGuideItems('T_EDUBASIS', false);
$e = new Zend_Form_Element_Select('edubase', array('label' => 'Форма фінансування', 'multiOptions' => $items, 'style' => 'width: 200px'));
$form->addElement($e);
$items = $this->getGuideItems('T_COUNTRYTYPE', false);
$e = new Zend_Form_Element_Select('countrytype', array('label' => 'Тип громадянства', 'multiOptions' => $items, 'style' => 'width: 200px'));
$form->addElement($e);
$refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
$e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
$form->addElement($e);
$excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 4));
$e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
$form->addElement($e);
$form->setElementDecorators(array('ViewHelper', 'Errors'));
return $form;
}
示例2: getForm
public function getForm()
{
$form = new Zend_Form();
$form->setMethod('post');
$form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report5Form.phtml'))));
$items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT_YEAR_SPEC');
$e = new Zend_Form_Element_Select('period', array('label' => 'Рік', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 80px'));
$form->addElement($e);
$items = $this->getGuideItems('T_REPORTPLANKIND');
$e = new Zend_Form_Element_Select('reportplankind', array('label' => 'Звіт/план', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 200px'));
$form->addElement($e);
$items = $this->getGuideItems('T_EDUFORM', false);
$e = new Zend_Form_Element_Select('eduform', array('label' => 'Форма навчання', 'multiOptions' => $items, 'style' => 'width: 200px'));
$form->addElement($e);
$items = $this->getGuideItems('T_EDUBASIS', false);
$e = new Zend_Form_Element_Select('edubase', array('label' => 'Форма фінансування', 'multiOptions' => $items, 'style' => 'width: 200px'));
$form->addElement($e);
$items = $this->getGuideItems('T_COUNTRYTYPE', true);
$e = new Zend_Form_Element_Select('countrytype', array('label' => 'Тип громадянства', 'multiOptions' => $items, 'style' => 'width: 200px'));
$form->addElement($e);
if (@(!$this->params['establishment'])) {
$e = new Zend_Form_Element_Checkbox('indpapers', array('label' => 'Індивідуальні аркуші'));
$form->addElement($e);
}
$refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
$e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
$form->addElement($e);
$excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 5));
$e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
$form->addElement($e);
$form->setElementDecorators(array('ViewHelper', 'Errors'));
return $form;
}
示例3: testAddDecoratorsKeepsNonNumericKeyNames
/**
* @group ZF-7552
*/
public function testAddDecoratorsKeepsNonNumericKeyNames()
{
$this->form->addDecorators(array(array(array('td' => 'HtmlTag'), array('tag' => 'td')), array(array('tr' => 'HtmlTag'), array('tag' => 'tr')), array('HtmlTag', array('tag' => 'baz'))));
$t1 = $this->form->getDecorators();
$this->form->setDecorators($t1);
$t2 = $this->form->getDecorators();
$this->assertEquals($t1, $t2);
}
示例4: testSettingElementDecoratorsWithConcreteDecoratorShouldHonorOrder
/**
* @group ZF-3597
*/
public function testSettingElementDecoratorsWithConcreteDecoratorShouldHonorOrder()
{
$this->form->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'table')), 'Form'));
$this->form->addElementPrefixPath('My_Decorator', dirname(__FILE__) . '/_files/decorators/', 'decorator');
$this->form->addElement('text', 'test', array('label' => 'Foo', 'description' => 'sample description'));
require_once dirname(__FILE__) . '/_files/decorators/TableRow.php';
$decorator = new My_Decorator_TableRow();
$this->form->setElementDecorators(array('ViewHelper', $decorator));
$html = $this->form->render($this->getView());
$this->assertRegexp('#<tr><td>Foo</td><td>.*?<input[^>]+>.*?</td><td>sample description</td></tr>#s', $html, $html);
}
示例5: setFormDefaults
/**
* Set Form defaults
* - disable default decorators
* - set form & displaygroup decorators
* - set needed prefix path for bootstrap decorators
* - set form element decorators
*
* @param Zend_Form $form The form instance.
* @param string $format Standard, minimal, table.
*
* @return void
*/
protected static function setFormDefaults(Zend_Form $form, $format)
{
$form->setDisableLoadDefaultDecorators(true);
$form->setDisplayGroupDecorators(self::$_DisplayGroupDecorator[$format]);
$form->setDecorators(self::$_FormDecorator[$format]);
if (self::BOOTSTRAP == $format || self::BOOTSTRAP_MINIMAL == $format) {
$form->addElementPrefixPath('Dfi_Form_Decorator', 'Dfi/Form/Decorator', Zend_Form::DECORATOR);
$form->addPrefixPath('Dfi_Form_Decorator', 'Dfi/Form/Decorator', Zend_Form::DECORATOR);
}
$form->setElementDecorators(self::$_ElementDecorator[$format]);
return;
}
示例6: getForm
public function getForm()
{
$form = new Zend_Form();
$form->setMethod(Zend_Form::METHOD_POST);
$form->setDecorators(array(array('ViewScript', array('viewScript' => 'requests/reqForm.phtml'))));
$items = $this->getGuideYears();
$e = new Zend_Form_Element_Select('year', array('label' => 'Рік', 'multiOptions' => $items, 'required' => true, 'value' => reset($items)));
$form->addElement($e);
$e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити'));
$form->addElement($e);
$form->setElementDecorators(array('ViewHelper', 'Errors'));
return $form;
}
示例7: getInfoForm
public function getInfoForm()
{
$form = new Zend_Form();
$form->setAction('')->setMethod(Zend_Form::METHOD_POST)->setAttrib('enctype', Zend_Form::ENCTYPE_MULTIPART);
$form->setDecorators(array(array('ViewScript', array('viewScript' => 'import/infoForm10.phtml'), 'Form')));
$e = new Zend_Form_Element_Hidden('step', array('value' => 2));
$form->addElement($e);
$e = new Zend_Form_Element_Hidden('filename');
$form->addElement($e);
$e = new Zend_Form_Element_Hidden('validreports');
$form->addElement($e);
$e = new Zend_Form_Element_Submit('submit', array('label' => 'Далі'));
$form->addElement($e);
$form->setElementDecorators(array('ViewHelper'));
return $form;
}
示例8: getForm
public function getForm()
{
$form = new Zend_Form();
$form->setMethod('post');
$form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report9Form.phtml'))));
$items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT_YEAR_SPEC');
$e = new Zend_Form_Element_Select('period', array('label' => 'Рік', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 80px'));
$form->addElement($e);
$refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
$e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
$form->addElement($e);
$excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 9));
$e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
$form->addElement($e);
$form->setElementDecorators(array('ViewHelper', 'Errors'));
return $form;
}
示例9: getForm
public static function getForm()
{
Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
$form = new Zend_Form();
$form->setDecorators(array(array('ViewScript', array('viewScript' => 'editor/changesForm.phtml'))));
$zdate = new Zend_Date();
$e = new Zend_Dojo_Form_Element_DateTextBox('fromDate', array('label' => 'From', 'required' => true));
$e->setAttrib('onchange', 'admin.currentManObj.refresh()');
$form->addElement($e);
$e = new Zend_Dojo_Form_Element_DateTextBox('toDate', array('label' => 'To', 'required' => true));
$e->setAttrib('onchange', 'admin.currentManObj.refresh()');
$form->addElement($e);
// $e = new Zend_Dojo_Form_Element_Button( 'refresh', array ('label' => 'Refresh' ) );
// $e->setAttrib('onchange', 'admin.currentManObj.refresh()');
// $form->addElement($e);
Zend_Dojo::enableForm($form);
$form->setDefaults(array('toDate' => $zdate->getIso(), 'fromDate' => $zdate->getIso()));
return $form;
}
示例10: getUploadForm
public static function getUploadForm()
{
$form = new Zend_Form();
$form->setAction('')->setMethod(Zend_Form::METHOD_POST)->setAttrib('enctype', Zend_Form::ENCTYPE_MULTIPART);
$form->setDecorators(array(array('ViewScript', array('viewScript' => 'import/uploadForm.phtml')), 'Errors'));
$f = new Zend_Form_Element_File('file');
//, array ('label' => 'Веберіть файл пакету') );
// $f->setAttrib ( 'style', 'width: 600px' );
$f->setRequired();
$f->addValidator('Count', false, 1);
// $f->addValidator ( 'Size', false, 204800 );
$f->addValidator('Extension', false, 'xls');
$cfg = Zend_Registry::get('cfg');
$target = $cfg['temp']['path'] . Zend_Auth::getInstance()->getIdentity()->NODEID . '.xls';
$f->addFilter('Rename', array('target' => $target, 'overwrite' => 'true'));
$form->addElement($f);
$e = new Zend_Form_Element_Submit('submit', array('label' => 'Завантажити'));
$form->addElement($e);
return $form;
}
示例11: build
public static function build($formConfig)
{
$decorators = array();
if ($formConfig->useInternalError) {
$decorators[] = new Saf_Form_Zend_Helper_Error(array('class' => 'formErrors', 'id' => $newFormId . 'Errors', 'placement' => 'append', 'escape' => false));
}
$newForm = new Zend_Form();
$newForm->setConfig($formConfig);
$newForm->removeDecorator('HtmlTag');
$newFormId = $newForm->getId();
$formDecorator = $newForm->getDecorator('Form');
$elementDecorator = $newForm->getDecorator('FormElements');
$decorators[] = $elementDecorator;
$decorators[] = $formDecorator;
$newForm->setDecorators($decorators);
foreach ($newForm->getElements() as $element) {
self::fixElement($element);
}
return $newForm;
}
示例12: getForm
public function getForm()
{
$form = new Zend_Form();
$form->setMethod('post');
$form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report8Form.phtml'))));
$items = $this->getPeriodItems('REQ_EDUSTAT_FAIL');
$e = new Zend_Form_Element_Select('period', array('label' => 'На дату', 'multiOptions' => $items, 'required' => true));
$form->addElement($e);
$items = $this->getGuideItems('T_DEPARTMENT', true);
$e = new Zend_Form_Element_Select('department', array('label' => 'Факультет', 'multiOptions' => $items, 'style' => 'width: 200px'));
$form->addElement($e);
$refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
$e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
$form->addElement($e);
$excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 8));
$e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
$form->addElement($e);
$form->setElementDecorators(array('ViewHelper', 'Errors'));
return $form;
}
示例13: getForm
public function getForm()
{
$form = new Zend_Form();
$form->setMethod('post');
$form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report1Form.phtml'))));
$items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT');
$e = new Zend_Form_Element_Select('period', array('label' => 'Період', 'multiOptions' => $items, 'required' => true));
$form->addElement($e);
$items = $this->getGuideItems('T_STRUCTURE_ITEM', true, false, 'CT.TITLE');
$e = new Zend_Form_Element_Select('establishment', array('label' => 'Установа', 'multiOptions' => $items));
$form->addElement($e);
$items = $this->getGuideItems('T_EDUFORM', true);
$e = new Zend_Form_Element_Select('eduform', array('label' => 'Форма навчання', 'multiOptions' => $items));
$form->addElement($e);
$items = $this->getGuideItems('T_EDUBASIS', true);
$e = new Zend_Form_Element_Select('edubase', array('label' => 'Форма фінансування', 'multiOptions' => $items));
$form->addElement($e);
$items = $this->getGuideItems('T_COUNTRY', true);
$e = new Zend_Form_Element_Select('country', array('label' => 'Громадянство (країна)', 'multiOptions' => $items));
$form->addElement($e);
$items = $this->getGuideItems('T_COUNTRYTYPE', true);
$e = new Zend_Form_Element_Select('countrytype', array('label' => 'Тип громадянства', 'multiOptions' => $items));
$form->addElement($e);
$items = $this->getGuideItems('T_EDULEVEL');
$e = new Zend_Form_Element_MultiCheckbox('edulevel', array('label' => 'Рівень підготовки', 'multiOptions' => $items));
$e->setValue(array_keys($items));
$form->addElement($e);
$refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
$e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
$form->addElement($e);
$excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 1));
$e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
$form->addElement($e);
$form->setElementDecorators(array('ViewHelper', 'Errors'));
$auth = Zend_Auth::getInstance();
$ident = $auth->getIdentity();
if ($ident->STRUCTURE_CODE != 0) {
$form->getElement('establishment')->setValue($ident->STRUCTUREID);
}
return $form;
}
示例14: getForm
/**
* @param unknown_type $formName
* @param unknown_type $options
* @throws Exception
* @return Zend_Form
*/
public function getForm($formName, $options = null, $useTemplate = false)
{
if (is_null(self::$_forms)) {
if (is_file(APPLICATION_PATH . '/configs/forms.ini')) {
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/forms.ini');
} else {
$config = new Zend_Config(include_once APPLICATION_PATH . '/configs/forms.php');
}
$config = $config->toArray();
self::$_forms = $config;
}
if (!array_key_exists($formName, $config)) {
throw new Exception("Form not exist");
}
if ($useTemplate) {
//$form = new Zend_Form_Template($config[$formName]);
//$form->setTemplate($formName, $options);
$form = new Zend_Form($config[$formName]);
$elements = $form->getElements();
foreach ($elements as &$element) {
$element->removeDecorator('Label');
$element->removeDecorator('HtmlTag');
$element->removeDecorator('DtDdWrapper');
$element->removeDecorator('Description');
$element->removeDecorator('Errors');
$element->addDecorator(array('data' => 'Errors'), array('tag' => 'p', 'class' => 'description'));
}
$filter = new Zend_Filter_Word_CamelCaseToDash();
$formName = $filter->filter($formName);
$options['viewScript'] = 'forms/' . $formName . '.phtml';
$form->setDecorators(array(array('viewScript', $options)));
} else {
$form = new Zend_Form($config[$formName]);
/* $form->addElementPrefixPath('Zend_Decorator',
'Zend/Decorator/',
'decorator');
$form->setDecorators(array('Default'));*/
//Zend_Debug::dump($form->getDecorator('Errors'));
/*$elements = $form->getElements();
foreach ($elements as &$element) {
$element->setDecorators(
array(
'ViewHelper',
'Errors',
array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element')),
'Label',
array(array('row' => 'HtmlTag'), array('tag' => 'li'))
)
);
//Zend_Debug::dump($element->getDecorator('Errors'));
};*/
/*
$form->setElementDecorators(array(
'ViewHelper',
array('Errors', array('class' => 'help-inline control-error')),
array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'controls')),
array(array('label' => 'Label'), array('class' => 'control-label')),
array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'control-group')),
));
*/
// $form->addElement("text", "naem", $opt);
/* $form->setDecorators(array(
'FormElements',
array('Form', array('class' => 'form-horizontal'))
));*/
//Zend_Debug::dump($form);
// вынести декораторы
}
$formAction = $form->getAction();
$routes = $this->getRouterNames();
$actionParams = array();
if (is_array($options) && array_key_exists('actionParams', $options)) {
$actionParams = $options['actionParams'];
}
if (in_array($formAction, $routes)) {
if (array_key_exists("actionParams", $config[$formName]) && is_array($config[$formName]['actionParams'])) {
$actionParams = $config[$formName]['actionParams'];
}
$form->setAction($this->_url($actionParams, $formAction));
}
//Zend_Debug::dump($form);
return $form;
}
示例15: array
$autoloader = Zend_Loader_Autoloader::getInstance();
$form = new Zend_Form();
// Set form name, id, method and action
$form->setName('fileUpload')->setAttrib('id', 'fileUpload')->setMethod('post')->setAttrib('enctype', 'multipart/form-data')->setAction('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
$file = new Zend_Form_Element_File('file');
$file->setLabel('File')->setRequired(true)->setValueDisabled(False)->addValidator('Extension', FALSE, 'jpg,jpeg')->addValidator('Size', false, array('min' => 20, 'max' => 20000000));
$file->getValidator('Extension')->setMessage('JPEGs only');
// Create text area for message
$message = new Zend_Form_Element_Textarea('message');
$message->setRequired(TRUE)->setAttrib('id', 'message')->addErrorMessage('Please specify a message');
// Create a submit button
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Submit')->setAttrib('id', 'submit');
// Set the ViewScript decorator for the form and tell it which
// template file to use
$form->setDecorators(array(array('ViewScript', array('viewScript' => 'form-contact.tpl.php'))));
// Add the form elements AFTER the viewscript decorator has been set
$form->addElements(array($file, $message, $submit));
// Get rid of all element decorators except for ViewHelper to render
// the individual elements and Errors decorator to render the errors.
$form->setElementDecorators(array('ViewHelper', 'Errors'));
// The file element requires the File decorator instead of the
// ViewHelper decorator
$file->setDecorators(array('File', 'Errors'));
// Create an instance of Zend_View and set the directory
// for the template files
$view = new Zend_View();
$view->setScriptPath(__DIR__);
// Tell all the elements in the form which view to use when rendering
foreach ($form as $item) {
$item->setView($view);