本文整理匯總了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;
}