本文整理汇总了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;
}
示例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;
}
示例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;
}