本文整理汇总了PHP中Zend\Form\Element::setOption方法的典型用法代码示例。如果您正苦于以下问题:PHP Element::setOption方法的具体用法?PHP Element::setOption怎么用?PHP Element::setOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\Element
的用法示例。
在下文中一共展示了Element::setOption方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __invoke
public function __invoke(Element $element)
{
$value = $element->getValue();
if (!$value) {
$value = 'default';
}
$view = $this->getView();
$default = $view->escapeHtmlAttr($view->basePath('img/avatars/' . $value . '.png'));
$id = uniqid('dialog-', false);
$element->setOption('dialog_id', $id);
$name = $view->escapeHtmlAttr($element->getName());
$html = <<<EOT
<div class="zource-avatar-selection zui-file-selection-trigger-container" data-zui-file-selection-trigger="#file-selection-{$id}">
<input type="hidden" name="{$name}" value="{$value}">
<p>
<img src="{$default}" alt="Avatar" tabindex="1" class="zui-file-selection-trigger-thumb">
</p>
</div>
EOT;
return $html;
}
示例2: testCanSetSingleOptionForLabel
public function testCanSetSingleOptionForLabel()
{
$element = new Element('foo');
$element->setOption('label', 'foo');
$option = $element->getOption('label');
$this->assertEquals('foo', $option);
}
示例3: generateFormElementByType
protected function generateFormElementByType($name, $type, $values = array(), $priority)
{
switch ($type) {
case 'FILE':
$elm = new Element\File();
$elm->setLabel(strtoupper($name));
break;
case 'SELECT':
$elm = new Element\Select($name);
$elm->setLabel(strtoupper($name));
$elm->setAttribute('id', $name . '_ID');
if ($values instanceof \Traversable || is_array($values)) {
$elm->setValueOptions($values);
}
break;
case 'DATE':
if (isset($option_elements['DateTimePicker']) && $option_elements['DateTimePicker']['status'] == 'enabled') {
$elm = new \Zf2datatable\Form\Element\DateCalendar($name);
$elm->setAttribute('id', $name . '_ID');
$elm->setAttribute('class', 'form-control');
$elm->setLabel($name);
$elm->setAttribute('jsOption', $option_elements['DateTimePicker']['options']['date_js_properties']);
\Zf2datatable\Form\Element\DateCalendar::setDateFormatIn($option_elements['DateTimePicker']['options']['date_format_in']);
\Zf2datatable\Form\Element\DateCalendar::setDateFormatOut($option_elements['DateTimePicker']['options']['date_format_out']);
} else {
$elm = new Element\Date($name);
$elm->setLabel(strtoupper($name));
$elm->setAttributes(array('type' => 'date'));
$elm->setFormat('Y-m-d');
}
break;
case 'DATETIME':
if (isset($option_elements['DateTimePicker']) && $option_elements['DateTimePicker']['status'] == 'enabled') {
$elm = new \Zf2datatable\Form\Element\DateTimeCalendar($name);
$elm->setAttribute('id', $name . '_ID');
$elm->setAttribute('class', 'form-control');
$elm->setLabel($name);
$elm->setAttribute('jsOption', $option_elements['DateTimePicker']['options']['datetime_js_properties']);
\Zf2datatable\Form\Element\DateTimeCalendar::setDateFormatIn($option_elements['DateTimePicker']['options']['datetime_format_in']);
\Zf2datatable\Form\Element\DateTimeCalendar::setDateFormatOut($option_elements['DateTimePicker']['options']['datetime_format_out']);
} else {
$elm = new Element\DateTimeSelect($name);
$elm->setLabel(strtoupper($name));
}
break;
default:
$elm = new Element($name);
$elm->setLabel(strtoupper($name));
$elm->setAttributes(array('type' => 'text'));
break;
}
$elm->setOption('priority', $priority);
return $elm;
}