当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Form::setDescription方法代码示例

本文整理汇总了PHP中Zend_Form::setDescription方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form::setDescription方法的具体用法?PHP Zend_Form::setDescription怎么用?PHP Zend_Form::setDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Form的用法示例。


在下文中一共展示了Zend_Form::setDescription方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCanSetDescription

 public function testCanSetDescription()
 {
     $this->testDescriptionInitiallyNull();
     $description = "This is a description";
     $this->form->setDescription($description);
     $this->assertEquals($description, $this->form->getDescription());
 }
开发者ID:vicfryzel,项目名称:zf,代码行数:7,代码来源:FormTest.php

示例2: 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;
 }
开发者ID:nuxwin,项目名称:i-PMS,代码行数:101,代码来源:Widget.php

示例3: array

<?php

ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '/path/to/zend/library');
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
$request = new Zend_Controller_Request_Http();
$view = new Zend_View();
/**
 * Example showing usage of array notation using setElementsBelongTo
 * on the form level, for shipping/billing addresses.
 */
$form = new Zend_Form();
$form->setView($view);
$form->addDecorator('Description', array('escape' => false, 'placement' => 'PREPEND'));
$form->setDescription('<h3>Using setElementsBelongTo</h3>');
$form->setElementsBelongTo('shipping');
$form->addElement('text', 'recipient', array('label' => 'Ship to', 'required' => true));
$form->addElement('text', 'address', array('label' => 'Address', 'required' => true));
$form->addElement('submit', 'submit', array('label' => 'Submit'));
if ($request->isPost()) {
    if ($form->isValid($request->getPost())) {
        echo 'Order placed, Thank you!';
    } else {
        echo 'You have errors in your form, please check';
    }
}
echo $form->render();
开发者ID:Tony133,项目名称:zf-web,代码行数:27,代码来源:Zend_Form_elementsBelongTo.php

示例4: array

<?php

ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '/path/to/zend/library');
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
$request = new Zend_Controller_Request_Http();
$view = new Zend_View();
/**
 * Example showing usage of array notation using belongsTo
 * for shipping/billing addresses.
 */
$form = new Zend_Form();
$form->setView($view);
$form->addDecorator('Description', array('escape' => false, 'placement' => 'PREPEND'));
$form->setDescription('<h3>Using belongsTo</h3>');
$form->addElement('text', 'recipient', array('label' => 'Ship to', 'required' => true, 'belongsTo' => 'shipping'));
$form->addElement('text', 'address1', array('label' => 'Address 1', 'required' => true, 'belongsTo' => 'shipping[addresses]'));
$form->addElement('submit', 'submit', array('label' => 'Submit'));
if ($request->isPost()) {
    if ($form->isValid($request->getPost())) {
        echo 'Order placed, Thank you!';
    } else {
        echo 'You have errors in your form, please check';
    }
}
echo $form->render();
开发者ID:Tony133,项目名称:zf-web,代码行数:26,代码来源:Zend_Form_belongsTo.php


注:本文中的Zend_Form::setDescription方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。