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


PHP Widget::__SelectBuildOption方法代码示例

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


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

示例1: Select

 /**
  * Generates a XMLElement representation of a `<select>`. This uses
  * the private function `__SelectBuildOption()` to build XMLElements of
  * options given the `$options` array.
  *
  * @see toolkit.Widget::__SelectBuildOption()
  * @param string $name
  *  The name attribute of the resulting `<select>`
  * @param array $options (optional)
  *  An array containing the data for each `<option>` for this
  *  `<select>`. If the array is associative, it is assumed that
  *  `<optgroup>` are to be created, otherwise it's an array of the
  *  containing the option data. If no options are provided an empty
  *  `<select>` XMLElement is returned.
  *  `
  *   array(
  *  	array($value, $selected, $desc, $class, $id, $attr)
  *   )
  *   array(
  *  	array('label' => 'Optgroup', 'options' = array(
  *  		array($value, $selected, $desc, $class, $id, $attr)
  *  	)
  *   )
  *  `
  * @param array $attributes (optional)
  *  Any additional attributes can be included in an associative array with
  *  the key being the name and the value being the value of the attribute.
  *  Attributes set from this array will override existing attributes
  *  set by previous params.
  * @return XMLElement
  */
 public static function Select($name, array $options = null, array $attributes = null)
 {
     General::ensureType(array('name' => array('var' => $name, 'type' => 'string')));
     $obj = new XMLElement('select');
     $obj->setAttribute('name', $name);
     $obj->setSelfClosingTag(false);
     if (is_array($attributes) && !empty($attributes)) {
         $obj->setAttributeArray($attributes);
     }
     if (!is_array($options) || empty($options)) {
         if (!isset($attributes['disabled'])) {
             $obj->setAttribute('disabled', 'disabled');
         }
         return $obj;
     }
     foreach ($options as $o) {
         //	Optgroup
         if (isset($o['label'])) {
             $optgroup = new XMLElement('optgroup');
             $optgroup->setAttribute('label', $o['label']);
             foreach ($o['options'] as $option) {
                 $optgroup->appendChild(Widget::__SelectBuildOption($option));
             }
             $obj->appendChild($optgroup);
         } else {
             $obj->appendChild(Widget::__SelectBuildOption($o));
         }
     }
     return $obj;
 }
开发者ID:bauhouse,项目名称:Piano-Sonata,代码行数:61,代码来源:class.widget.php

示例2: Select

 function Select($name, $options, $attributes = NULL)
 {
     $obj = new XMLElement('select');
     $obj->setAttribute('name', $name);
     $obj->setSelfClosingTag(false);
     if (is_array($attributes) && !empty($attributes)) {
         foreach ($attributes as $key => $value) {
             $obj->setAttribute($key, $value);
         }
     }
     if (!is_array($options) || empty($options)) {
         if (!isset($attributes['disabled'])) {
             $obj->setAttribute('disabled', 'disabled');
         }
         //$option = new XMLElement('option', ' ');
         //$option->setAttribute('value', '');
         //$obj->appendChild($option);
         return $obj;
     }
     foreach ($options as $o) {
         ## Opt Group
         if (isset($o['label'])) {
             $optgroup = new XMLElement('optgroup');
             $optgroup->setAttribute('label', $o['label']);
             foreach ($o['options'] as $opt) {
                 $optgroup->appendChild(Widget::__SelectBuildOption($opt));
             }
             $obj->appendChild($optgroup);
         } else {
             $obj->appendChild(Widget::__SelectBuildOption($o));
         }
     }
     return $obj;
 }
开发者ID:bauhouse,项目名称:sym-fluidgrids,代码行数:34,代码来源:class.widget.php

示例3: Select

 public static function Select($name, $options, array $attributes = NULL)
 {
     $obj = Widget::$Symphony->createElement('select');
     $attributes['name'] = $name;
     if (!is_null($attributes)) {
         $obj->setAttributeArray($attributes);
     }
     $obj->appendChild(Widget::$Symphony->createTextNode(''));
     if (!is_array($options) || empty($options)) {
         if (is_null($attributes) || !isset($attributes['disabled'])) {
             $obj->setAttribute('disabled', 'disabled');
         }
         return $obj;
     }
     foreach ($options as $o) {
         ## Opt Group
         if (isset($o['label'])) {
             $optgroup = Widget::$Symphony->createElement('optgroup');
             $optgroup->setAttribute('label', $o['label']);
             foreach ($o['options'] as $opt) {
                 $optgroup->appendChild(Widget::__SelectBuildOption($opt));
             }
             $obj->appendChild($optgroup);
         } else {
             $obj->appendChild(Widget::__SelectBuildOption($o));
         }
     }
     return $obj;
 }
开发者ID:brendo,项目名称:symphony-3,代码行数:29,代码来源:class.widget.php


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