本文整理汇总了PHP中Zend_Form_Element_Hidden::getDecorator方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_Element_Hidden::getDecorator方法的具体用法?PHP Zend_Form_Element_Hidden::getDecorator怎么用?PHP Zend_Form_Element_Hidden::getDecorator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form_Element_Hidden
的用法示例。
在下文中一共展示了Zend_Form_Element_Hidden::getDecorator方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Form initialization
*
* @return void
*/
public function init()
{
$this->setName('loginForm');
$this->setElementsBelongTo('loginForm');
$element = new Zend_Form_Element_Text('username');
$element->setLabel('Username')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim');
$this->addElement($element);
$element = new Zend_Form_Element_Password('password');
$element->setLabel('Password')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim');
$this->addElement($element);
$element = new Zend_Form_Element_Checkbox('rememberMe');
$element->setLabel('Remember me');
$this->addElement($element);
/**
* @var $request Zend_Controller_Request_Http
*/
$request = Zend_Controller_Front::getInstance()->getRequest();
$element = new Zend_Form_Element_Hidden('redirect');
$element->setValue($request->getParam('from', '/'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim');
$element->getDecorator('HtmlTag')->setOption('class', 'hidden');
$element->getDecorator('Label')->setOption('tagClass', 'hidden');
$this->addElement($element);
$element = new Zend_Form_Element_Submit('submit');
$element->setLabel('Connection');
$this->addElement($element);
}
示例2: init
/**
* Build easy mail form
*
* @return void
*/
public function init()
{
// Create and configure query field elements:
$recipient = new Zend_Form_Element_Text('recipient');
$recipient->setRequired(false);
$recipient->setLabel('frontdoor_recipientname');
$recipient_mail = new Zend_Form_Element_Text('recipient_mail');
$recipient_mail->setRequired(true);
$recipient_mail->setLabel('frontdoor_recipientmail');
$sender = new Zend_Form_Element_Text('sender');
$sender->setRequired(false);
$sender->setLabel('frontdoor_sendername');
$sender_mail = new Zend_Form_Element_Text('sender_mail');
$sender_mail->setRequired(false);
$sender_mail->setLabel('frontdoor_sendermail');
$message = new Zend_Form_Element_Textarea('message');
$message->setRequired(false);
$message->setLabel('frontdoor_messagetext');
$title = new Zend_Form_Element_Hidden('title');
$htmlTag = $title->getDecorator('htmlTag');
$htmlTag->setOption('tag', 'div');
$title->removeDecorator('label');
$doc_id = new Zend_Form_Element_Hidden('doc_id');
$htmlTag = $doc_id->getDecorator('htmlTag');
$htmlTag->setOption('tag', 'div');
$doc_id->removeDecorator('label');
$doc_type = new Zend_Form_Element_Hidden('doc_type');
$htmlTag = $doc_type->getDecorator('htmlTag');
$htmlTag->setOption('tag', 'div');
$doc_type->removeDecorator('label');
$submit = new Zend_Form_Element_Submit('frontdoor_send_recommendation');
$submit->setLabel('frontdoor_sendrecommendation');
// Add elements to form:
$this->addElements(array($recipient, $recipient_mail, $sender, $sender_mail, $message, $title, $doc_id, $doc_type, $submit));
}
示例3: getForm
//.........这里部分代码省略.........
}
$formDef = $this->getFormDefinition($form);
if (!array_key_exists('type', $formDef['element'])) {
$formDef = $formDef['element'];
}
$elementStack = array();
foreach ($formDef as $elementDef) {
/**
* @var $element Zend_Form_Element|Zend_Form_Element_Select
*/
$className = 'Zend_Form_Element_' . ucfirst($elementDef['type']);
$element = new $className($elementDef['name'], array('label' => isset($elementDef['label']) ? $elementDef['label'] : '', 'value' => isset($elementDef['val']) ? $elementDef['val'] : '', 'helper' => 'form' . ucfirst($elementDef['type']), 'required' => isset($elementDef['required']) ? (int) $elementDef['required'] : 0));
if ($elementDef['type'] == 'select') {
if (isset($elementDef['option'])) {
foreach ($elementDef['option'] as $option) {
$element->addMultiOptions(array($option['val'] => $option['label']));
if (isset($option['selected'])) {
$element->setValue($option['val']);
}
}
} elseif (isset($elementDef['callback'])) {
if (isset($elementDef['callback']['function'])) {
$options = call_user_func_array($elementDef['callback']['function'], (array) isset($elementDef['callback']['argument']) ? $elementDef['callback']['argument'] : array());
if ($elementDef['callback']['function'] == 'range') {
$options = array_combine($options, $options);
}
$element->addMultiOptions($options);
if (isset($elementDef['callback']['selected'])) {
$element->setValue($elementDef['callback']['selected']);
}
} else {
require_once 'iPMS/Widgets/Exception.php';
throw new iPMS_Widgets_Exception('Unable to generate element options from callback: function name not found');
}
} else {
require_once 'iPMS/Widgets/Exception.php';
throw new iPMS_Widgets_Exception('All select elements must have options');
}
}
if (isset($elementDef['id'])) {
// Optional CSS id for element
$element->setAttrib('id', $elementDef['id']);
}
if (isset($elementDef['class'])) {
// Optional CSS class for element
$element->setAttrib('class', $elementDef['class']);
}
if (isset($elementDef['filter'])) {
// Optional filter(s) for element
$element->addFilters((array) $elementDef['filter']);
}
// Optional validator for element
if (isset($elementDef['validator'])) {
// Optional validator for element
$element->addValidators((array) $elementDef['validator']);
}
$elementStack[] = $element;
}
// Creating new form instance
$formInstance = new Zend_Form();
$formInstance->setName($form)->setElementsBelongTo($form)->addElements($elementStack);
// Optional description for the Form
if (isset($formDef['description'])) {
$formInstance->setDescription($formDef['description'])->addDecorator('Description', array('placement' => 'prepend'));
}
} elseif (is_array($form) && isset($form['clasname'])) {
// Form generated from specific class
$className = $form['clasname'];
if (isset($this->_formInstances[$className])) {
return $this->_formInstances[$className];
}
if (!class_exists($className)) {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($className, isset($form['path']) ? isset($form['path']) : null);
}
$formInstance = new $className();
if (!$formInstance instanceof Zend_Form) {
require_once 'iPMS/Widgets/Exception.php';
throw new iPMS_Widgets_Exception(sprintf('Invalid argument: Detected class "%s", which is not an instance of Zend_Form', $className));
}
} else {
require_once 'iPMS/Widgets/Exception.php';
throw new iPMS_Widgets_Exception('Invalid argument $form');
}
// Common treatment
if ($form !== 'dashboard') {
$hidden = new Zend_Form_Element_Hidden('widgetUpdate');
$hidden->setValue($this . '_' . $this->_id)->setRequired(true);
$hidden->getDecorator('HtmlTag')->setOption('class', 'hidden');
$hidden->getDecorator('Label')->setOption('tagClass', 'hidden');
$formInstance->addElement($hidden);
}
// Add a submit element if it doesn't already defined
if (null === $formInstance->getElement('submit')) {
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('submit');
$formInstance->addElement($submit);
}
return $this->_formInstances[isset($className) ? $className : $form] = $formInstance;
}
示例4: createToolbar
/**
* Cria a toolbar.
* @param Boolean $save define se irá aparecer o botão padrão Salvar.
* @param Boolean $saveClose Botão para salvar e fechar
* @param Boolean $printForm Botão para imprimir
* @param Boolean $deleteForm Botão para deletar
* @param Boolean $clearForm Botão limpar dados de um formulário
* @param Boolean $includeForm Botão para incluir
* @param Boolean $editForm Botão para editar
* @param Boolean $backForm Botão para voltar
* @param Boolean $execute Botão para executar processo [GAMBI]
* @param Boolean $returnPendency Botão para processar dados [GAMBI]
* @param Boolean $processData Botão para processar dados [GAMBI]
* @param Boolean $block Botão para bloquear recursos [GAMBI]
* @param Boolean $disable Botão para desativar recursos [GAMBI]
*/
public function createToolbar($save = false, $saveClose = false, $printForm = false, $deleteForm = false, $clearForm = false, $includeForm = false, $editForm = false, $backForm = false, $execute = false, $returnPendency = false, $processData = false, $block = false, $disable = false, array $params = null)
{
$elementsList = array();
$elementsNameList = array();
if ($save) {
$saveForm = new Zend_Form_Element_Submit('saveForm');
$saveForm->setLabel('Salvar');
$saveForm->setAttrib('class', 'save');
$saveForm->setDecorators(array(array('ViewHelper'), array('description'), array('HtmlTag', array('tag' => 'li'))));
$elementsList[] = $saveForm;
$elementsNameList[] = "saveForm";
}
if ($saveClose) {
$saveCloseForm = new Zend_Form_Element_Submit('saveCloseForm');
// $saveCloseForm = new Zend_Form_Element_Hidden('saveCloseForm');
$saveCloseForm->setLabel('Salvar/Fechar');
$saveCloseForm->setAttrib('class', 'save_close');
// $saveCloseForm->setDescription('<a href="" class="save_close" id="save_close">Salvar/Fechar</a>');
$saveCloseForm->setDecorators(array(array('ViewHelper'), array('description'), array('HtmlTag', array('tag' => 'li'))));
$saveCloseForm->getDecorator('description')->setOption('escape', false);
$elementsList[] = $saveCloseForm;
$elementsNameList[] = "saveCloseForm";
}
if ($execute) {
$execute = new Zend_Form_Element_Hidden('execute');
$execute->setDescription('<a href="" id="execute" class="execute">Executar</a>');
$execute->setDecorators(array(array('description'), array('HtmlTag', array('tag' => 'li', 'class' => 'execute'))));
$execute->getDecorator('description')->setOption('escape', false);
$elementsList[] = $execute;
$elementsNameList[] = "execute";
}
if ($returnPendency) {
$returnPendency = new Zend_Form_Element_Hidden('returnPendency');
$returnPendency->setDescription('<a href="" id="rtPendency" class="back">Retornar pendência</a>');
$returnPendency->setDecorators(array(array('description'), array('HtmlTag', array('tag' => 'li', 'class' => 'back'))));
$returnPendency->getDecorator('description')->setOption('escape', false);
$elementsList[] = $returnPendency;
$elementsNameList[] = "returnPendency";
}
if ($processData) {
$processData = new Zend_Form_Element_Hidden('processData');
$processData->setDescription('<a href="" id="processData" class="process">Dados do processo</a>');
$processData->setDecorators(array(array('description'), array('HtmlTag', array('tag' => 'li', 'class' => 'process'))));
$processData->getDecorator('description')->setOption('escape', false);
$elementsList[] = $processData;
$elementsNameList[] = "processData";
}
if ($clearForm) {
$clearForm = new Zend_Form_Element_Hidden('clearForm');
$clearForm->setDescription('<a href="" id="clear_btn" class="clean">Limpar</a>');
$clearForm->setDecorators(array(array('description'), array('HtmlTag', array('tag' => 'li', 'class' => 'clear'))));
$clearForm->getDecorator('description')->setOption('escape', false);
$elementsList[] = $clearForm;
$elementsNameList[] = "clearForm";
}
if ($includeForm) {
$includeForm = new Zend_Form_Element_Hidden('includeForm');
$includeForm->setDescription('<a href="#" id="include_btn" class="include">Incluir</a>');
$includeForm->setDecorators(array(array('ViewHelper'), array('description'), array('HtmlTag', array('tag' => 'li', 'class' => 'include'))));
$includeForm->getDecorator('description')->setOption('escape', false);
$elementsList[] = $includeForm;
$elementsNameList[] = "includeForm";
}
if ($editForm) {
$editForm = new Zend_Form_Element_Hidden('editForm');
$editForm->setDescription('<a href="#" id="edit_btn" class="edit">Editar</a>');
$editForm->setDecorators(array(array('ViewHelper'), array('description'), array('HtmlTag', array('tag' => 'li', 'class' => 'edit'))));
$editForm->getDecorator('description')->setOption('escape', false);
$elementsList[] = $editForm;
$elementsNameList[] = "editForm";
}
if ($deleteForm) {
$deleteForm = new Zend_Form_Element_Hidden('deleteForm');
$deleteForm->setDescription('<a href="" id="delete_btn" class="delete">Excluir</a>');
$deleteForm->setDecorators(array(array('description'), array('HtmlTag', array('tag' => 'li', 'class' => 'delete'))));
$deleteForm->getDecorator('description')->setOption('escape', false);
$elementsList[] = $deleteForm;
$elementsNameList[] = "deleteForm";
}
if ($block) {
$block = new Zend_Form_Element_Hidden('blockForm');
$block->setDescription('<a href="" id="block_btn" class="block">Bloquear/Desbloquear</a>');
$block->setDecorators(array(array('description'), array('HtmlTag', array('tag' => 'li', 'class' => 'block'))));
$block->getDecorator('description')->setOption('escape', false);
//.........这里部分代码省略.........
示例5: init
/**
* Form initialization
*
* @return void
*/
public function init()
{
$this->setName('postForm')->setAction('/post/add')->setElementsBelongTo('postForm')->setMethod('post')->setEnctype('application/x-www-form-urlencoded');
$element = new Zend_Form_Element_Text('title');
$element->setLabel('Title')->setAttrib('class', 'inputTitle')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
$this->addElement($element);
$element = new Zend_Form_Element_Textarea('teaser');
$element->setLabel('Teaser')->setAttrib('class', 'inputSummary')->setAttrib('rows', '5')->setRequired(true)->addFilter('StripTags', array('allowTags' => $this->_allowedXhtmlTags, 'allowAttribs' => $this->_allowedXhtmlAttributes))->addFilter('StringTrim');
$this->addElement($element);
$element = clone $element;
$element = new Zend_Form_Element_Textarea('body');
$element->setLabel('Content')->setAttrib('class', 'input-body')->setAttrib('rows', '25')->setRequired(true)->addFilter('StripTags', array('allowTags' => $this->_allowedXhtmlTags, 'allowAttribs' => $this->_allowedXhtmlAttributes))->addFilter('StringTrim');
$this->addElement($element);
$element = new Zend_Form_Element_Checkbox('allow_comments');
$element->setLabel('Open for new comments ?')->setValue('1');
$this->addElement($element);
$element = new Zend_Form_Element_Hidden('pid');
$element->getDecorator('Label')->setOption('tagClass', 'hidden');
$element->getDecorator('HtmlTag')->setOption('class', 'hidden');
$this->addElement($element);
$element = new Zend_Form_Element_Hidden('categorie');
$element->setValue('home');
$element->getDecorator('Label')->setOption('tagClass', 'hidden');
$element->getDecorator('HtmlTag')->setOption('class', 'hidden');
$this->addElement($element);
$element = new Zend_Form_Element_Submit('postSubmit');
$element->setLabel('Submit');
$this->addElement($element);
$this->_setRequiredSuffix();
}