本文整理汇总了PHP中Zend\Form\ElementInterface::getOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP ElementInterface::getOptions方法的具体用法?PHP ElementInterface::getOptions怎么用?PHP ElementInterface::getOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\ElementInterface
的用法示例。
在下文中一共展示了ElementInterface::getOptions方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Render editor
*
* @param ElementInterface $element
*
* @throws \Zend\Form\Exception\DomainException
* @return string
*/
public function render(ElementInterface $element)
{
$renderer = $this->getView();
if (!method_exists($renderer, 'plugin')) {
// Bail early if renderer is not pluggable
return '';
}
$name = $element->getName();
if (empty($name) && $name !== 0) {
throw new Exception\DomainException(sprintf('%s requires that the element has an assigned name;' . ' none discovered', __METHOD__));
}
$options = $element->getOptions();
/*
$attributes = $element->getAttributes();
$attributes['value'] = $element->getValue();
$options['attributes'] = $attributes;
*/
$editorType = $element->getOption('editor') ?: 'textarea';
$editor = EditorFactory::load($editorType, $options);
$html = '';
if ($editor) {
$html = $editor->setView($renderer)->render($element);
}
if (!$html) {
$html = $renderer->formTextarea($element);
}
return $html;
}
示例2: render
/**
* @see \Zend\Form\View\Helper\FormRadio::render()
* @param \Zend\Form\ElementInterface $oElement
* @return string
*/
public function render(ElementInterface $oElement)
{
$aElementOptions = $oElement->getOptions();
if (isset($aElementOptions['disable-twb']) && $aElementOptions['disable-twb'] == true) {
$sSeparator = $this->getSeparator();
$this->setSeparator('');
$sReturn = parent::render($oElement);
$this->setSeparator($sSeparator);
return $sReturn;
}
if (isset($aElementOptions['inline']) && $aElementOptions['inline'] == true) {
$sSeparator = $this->getSeparator();
$this->setSeparator('');
$oElement->setLabelAttributes(array('class' => 'radio-inline'));
$sReturn = sprintf('%s', parent::render($oElement));
$this->setSeparator($sSeparator);
return $sReturn;
}
if (isset($aElementOptions['btn-group']) && $aElementOptions['btn-group'] == true) {
$this->setSeparator('');
$oElement->setLabelAttributes(array('class' => 'btn btn-primary'));
return sprintf('<div class="btn-group" data-toggle="buttons">%s</div>', parent::render($oElement));
}
return sprintf(self::$checkboxFormat, parent::render($oElement));
}
示例3: render
public function render(ElementInterface $element)
{
$name = $element->getName();
if (empty($name) && $name !== 0) {
throw new Exception\DomainException(sprintf('%s requires that the element has an assigned name; none discovered', __METHOD__));
}
$attributes = $element->getAttributes();
$attributes['name'] = $name;
$content = (string) $element->getValue();
$escapeHtml = $this->getEscapeHtmlHelper();
//ADD OPTIONS
// this should really be in Stjonvisi\Form\Element\Img
// but it gets overwritten at some point, so the simplest
// thing was to add it here.
// TODO place this i a more generic place
$element->setOption('max', $this->getMaxSize())->setOption('mime', '/image\\/jpg|png|gif/')->setOption('url', '/skrar/mynd');
//OPTIONS
// options are used to set attributes and values
// to the custom element. We therefore need to remove
// label, label_attributes and label_options before we
// can convert them into an attribute string.
$options = $element->getOptions();
unset($options['label']);
unset($options['label_attributes']);
unset($options['label_options']);
$strings = array_map(function ($key, $value) {
return sprintf('%s="%s"', $key, $value);
}, array_keys($options), $options);
return sprintf('<stjornvisi-rich %s><textarea %s>%s</textarea></stjornvisi-rich>', implode(' ', $strings), $this->createAttributesString($attributes), $escapeHtml($content));
}
示例4: render
/**
* @see FormMultiCheckbox::render()
* @param ElementInterface $oElement
* @return string
*/
public function render(ElementInterface $oElement)
{
$aElementOptions = $oElement->getOptions();
// For inline multi-checkbox
if (isset($aElementOptions['inline']) && $aElementOptions['inline'] == true) {
$this->setSeparator('');
$oElement->setLabelAttributes(array('class' => 'checkbox-inline'));
return sprintf('%s', parent::render($oElement));
}
$this->setSeparator('</div><div class="checkbox">');
$oElement->setLabelAttributes(array('class' => 'checkbox'));
return sprintf('<div class="checkbox">%s</div>', parent::render($oElement));
}
示例5: render
/**
* @see \Zend\Form\View\Helper\FormMultiCheckbox::render()
* @param \Zend\Form\ElementInterface $oElement
* @return string
*/
public function render(\Zend\Form\ElementInterface $oElement)
{
$aElementOptions = $oElement->getOptions();
$sCheckboxClass = isset($aElementOptions['inline']) && $aElementOptions['inline'] == false ? 'checkbox' : 'checkbox-inline';
$aLabelAttributes = $oElement->getLabelAttributes();
if (empty($aLabelAttributes['class'])) {
$aLabelAttributes['class'] = $sCheckboxClass;
} elseif (!preg_match('/(\\s|^)' . $sCheckboxClass . '(\\s|$)/', $aLabelAttributes['class'])) {
$aLabelAttributes['class'] .= ' ' . $sCheckboxClass;
}
$oElement->setLabelAttributes($aLabelAttributes);
return parent::render($oElement);
}
示例6: render
/**
* @see \Zend\Form\View\Helper\FormMultiCheckbox::render()
* @param \Zend\Form\ElementInterface $oElement
* @return string
*/
public function render(\Zend\Form\ElementInterface $oElement)
{
$aElementOptions = $oElement->getOptions();
// For no inline multi-checkbox
if ($bNoInline = isset($aElementOptions['inline']) && $aElementOptions['inline'] == false) {
$sCheckboxClass = 'checkbox';
$this->setSeparator('</div><div class="checkbox">');
} else {
$sCheckboxClass = 'checkbox-inline';
$this->setSeparator('');
}
$oElement->setLabelAttributes(array('class' => $sCheckboxClass));
return $bNoInline ? '<div class="checkbox">' . parent::render($oElement) . '</div>' : parent::render($oElement);
}
示例7: render
/**
* @see \Zend\Form\View\Helper\FormRadio::render()
* @param \Zend\Form\ElementInterface $oElement
* @return string
*/
public function render(ElementInterface $oElement)
{
$aElementOptions = $oElement->getOptions();
if (isset($aElementOptions['disable-twb']) && $aElementOptions['disable-twb'] == true) {
$sSeparator = $this->separator;
$this->separator = '';
$sReturn = parent::render($oElement);
$this->separator = $sSeparator;
return $sReturn;
}
if (isset($aElementOptions['inline']) && $aElementOptions['inline'] == true) {
$this->setSeparator('');
$oElement->setLabelAttributes(array('class' => 'radio-inline'));
return sprintf('%s', parent::render($oElement));
}
return sprintf(self::$checkboxFormat, parent::render($oElement));
}
示例8: render
/**
* Renders editor contents
*
* @param ElementInterface $element
* @return string
*/
public function render(ElementInterface $element)
{
$options = array_merge($this->getOptions(), $element->getOptions());
$attributes = array_merge($this->getAttributes(), $element->getAttributes());
// Set up language
if (!isset($options['language'])) {
$options['language'] = Pi::service('i18n')->locale;
}
$options['language'] = strtolower(str_replace('_', '-', $options['language']));
$basePath = isset($options['base_path']) ? $options['base_path'] : Pi::path('www') . '/script/editor/ckeditor';
include_once $basePath . '/ckeditor.php';
include_once __DIR__ . '/Ckeditor.php';
$baseUrl = isset($options['base_url']) ? $options['base_url'] : Pi::url('www') . '/script/editor/ckeditor/';
$ckEditor = new Ckeditor($baseUrl);
$ckEditor->returnOutput = true;
$ckEditor->textareaAttributes = array_merge($ckEditor->textareaAttributes, $attributes);
$this->setupFinder($ckEditor, $options);
return $ckEditor->editor($element->getName(), $element->getValue(), $options);
}
示例9: render
/**
* Over writes render method to put layout array into the correct format for
* Zend Form
*
* @param ElementInterface $element Zend Element Interface
*
* @return string|void
* @throws InvalidArgumentException
*/
public function render(ElementInterface $element)
{
if (!$element instanceof MainLayout) {
throw new InvalidArgumentException(sprintf('%s requires that the element is of type PageLayout', __METHOD__));
}
$options = $element->getOptions();
$element->setLabelOption('disable_html_escape', true);
$inputOptions = [];
foreach ($options['layouts'] as $key => &$layout) {
$inputOptions[$key] = "\n" . '<span class="pageLayoutLabel">' . "\n" . ' <img src="' . $layout['screenShot'] . '" />' . "\n" . ' <span class="pageLayoutTextDisplay">' . "\n" . ' ' . $layout['display'] . "\n" . ' </span>' . "\n" . ' <span class="pageLayoutImageOverlay"></span>' . "\n" . '</span>' . "\n";
}
$name = static::getName($element);
$options = $inputOptions;
$attributes = $element->getAttributes();
$attributes['name'] = $name;
$attributes['type'] = $this->getInputType();
$selectedOptions = (array) $element->getValue();
$rendered = $this->renderOptions($element, $options, $selectedOptions, $attributes);
return $rendered;
}
示例10: render
/**
* Renders editor contents
*
* @param ElementInterface $element
* @return string
*/
public function render(ElementInterface $element)
{
$options = array_merge($this->getOptions(), $element->getOptions());
$attributes = array_merge($this->getAttributes(), $element->getAttributes());
$view = $this->view;
// Set up set and skin
$set = isset($options['set']) ? $options['set'] : 'html';
$skin = isset($options['skin']) ? $options['skin'] : 'simple';
// Set up CSS
$view->css(sprintf('%s/editor/markitup/skins/%s/style.css', Pi::url('script'), $skin));
$view->css(sprintf('%s/editor/markitup/sets/%s/style.css', Pi::url('script'), $set));
// Set up JavaScript
$view->jQuery();
$view->js(Pi::url('script') . '/editor/markitup/jquery.markitup.js');
$view->js(sprintf('%s/editor/markitup/sets/%s/set.js', Pi::url('script'), $set));
$parserpath = '';
if (!empty($options['sets'][$set]['parser_path'])) {
$parserpath = $options['sets'][$set]['parser_path'];
} else {
$path = sprintf('%s/editor/markitup/sets/%s/preview.php', Pi::path('script'), $set);
if (file_exists($path)) {
$parserpath = sprintf('~/sets/%s/preview.php', $set);
}
}
$scriptJs = <<<EOT
\$(document).ready(function() {
mySettings.previewParserPath = '{$parserpath}';
mySettings.previewParserVar = 'preview';
\$('#%s').markItUp(mySettings);
});
EOT;
if (isset($attributes['id'])) {
$id = $attributes['id'];
} else {
$id = uniqid($element->getName());
}
$element->setAttribute('id', $id);
$js = sprintf($scriptJs, $id);
$view->HeadScript('script', $js);
}
示例11: render
/**
* @param ElementInterface $element
*
* @return string
*/
public function render(ElementInterface $element)
{
$name = $element->getName();
if (empty($name) && $name !== 0) {
throw new \DomainException(sprintf('%s requires that the element has an assigned name; none discovered', __METHOD__));
}
/* @var \Zend\View\Renderer\PhpRenderer $renderer */
$renderer = $this->getView();
/* @var \Zend\View\Helper\HeadScript $headscript */
$headscript = $renderer->plugin('headscript');
/* @var \Zend\View\Helper\BasePath $basepath */
$basepath = $renderer->plugin('basepath');
$headscript->appendFile($basepath('js/tinymce/tinymce.jquery.min.js'));
$headscript->prependFile($basepath('js/jquery.min.js'));
$headscript->offsetSetScript('1000_tinymce_' . $this->getTheme(), '
$(document).ready(function() {
tinyMCE.init({' . $this->additionalOptions() . ',
setup: function(editor) {
setPlaceHolder = function(editor, show) {
placeHolder = $("#placeholder-" + editor.id);
if (placeHolder.length == 1) {
if (show && editor.getContent() == "") {
placeHolder.show();
}
else {
placeHolder.hide();
}
}
},
editor.on("focus", function(e) {
setPlaceHolder(editor, false);
});
editor.on("blur", function(e) {
setPlaceHolder(editor, true);
if (editor.isDirty()) {
//console.log("blur event", e);
editor.save();
var container = e.target.bodyElement;
$(container).parents("html").addClass("yk-changed");
var form = $(container).parents("form");
//console.log("form", form, container);
form.submit();
$(form).on("yk.forms.done", function(){
console.log("done");
//$(container).parents("html").removeClass("yk-changed");
});
}
});
}
});
});');
$attributes = $element->getAttributes();
$attributes['name'] = $name;
$attributes['id'] = $name;
$content = $element->getValue();
if (!isset($content)) {
$content = '';
}
if (is_string($content)) {
$class = array_key_exists('class', $attributes) ? $attributes['class'] : '';
$class .= (empty($class) ?: ' ') . ' tinymce_' . $this->getTheme();
$attributes['class'] = $class;
$placeHolder = '';
$elementOptions = $element->getOptions();
if (array_key_exists('placeholder', $elementOptions) && !empty($elementOptions['placeholder'])) {
$placeHolder = '<div id="placeholder-' . $name . '" style="border: 0 none; position: relative; top: 0ex; left: 10px; color: #aaa; height: 0px; overflow: visible;' . (empty($content) ? '' : 'display:none;') . '">' . $this->translator->translate($elementOptions['placeholder']) . '</div>';
}
return $placeHolder . sprintf('<div %s >%s</div>', $this->createAttributesString($attributes), $content);
} else {
return (string) $content;
}
}
示例12: render
public function render(ElementInterface $element)
{
$name = $element->getName();
if (empty($name) && $name !== 0) {
throw new \DomainException(sprintf('%s requires that the element has an assigned name; none discovered', __METHOD__));
}
$renderer = $this->getView();
$headscript = $renderer->plugin('headscript');
$basepath = $renderer->plugin('basepath');
$headscript->appendFile($basepath('js/tinymce/tinymce.jquery.min.js'));
$headscript->prependFile($basepath('js/jquery.min.js'));
//
// mode : "textareas",
$headscript->offsetSetScript('1000_tinymce_' . $this->getTheme(), '
$(document).ready(function() {
tinyMCE.init({
selector : "div.tinymce_' . $this->getTheme() . '",
inline : true,
theme : "modern",
plugins: [
"advlist autolink lists charmap anchor",
"searchreplace visualblocks code fullscreen",
"contextmenu paste textcolor"
],
//toolbar1: "forecolor",
removed_menuitems: "newdocument",' . PHP_EOL . $this->additionalOptions() . 'setup: function(editor) {
setPlaceHolder = function(editor, show) {
placeHolder = $("#placeholder-" + editor.id);
if (placeHolder.length == 1) {
if (show && editor.getContent() == "") {
placeHolder.show();
}
else {
placeHolder.hide();
}
}
},
editor.on("focus", function(e) {
setPlaceHolder(editor, false);
});
editor.on("blur", function(e) {
setPlaceHolder(editor, true);
if (editor.isDirty()) {
//console.log("blur event", e);
editor.save();
var container = e.target.bodyElement;
$(container).parents("html").addClass("yk-changed");
var form = $(container).parents("form");
//console.log("form", form, container);
form.submit();
$(form).on("yk.forms.done", function(){
console.log("done");
//$(container).parents("html").removeClass("yk-changed");
});
}
});
}
});
});
');
$attributes = $element->getAttributes();
$attributes['name'] = $name;
$attributes['id'] = $name;
$content = $element->getValue();
if (!isset($content)) {
$content = '';
}
if (is_string($content)) {
// content is should be in an ordinary textarea
$escapeHtml = $this->getEscapeHtmlHelper();
$class = array_key_exists('class', $attributes) ? $attributes['class'] : '';
$class .= (empty($class) ?: ' ') . ' tinymce_' . $this->getTheme();
$attributes['class'] = $class;
$placeHolder = '';
$elementOptions = $element->getOptions();
if (array_key_exists('placeholder', $elementOptions) && !empty($elementOptions['placeholder'])) {
$placeHolder = '<div id="placeholder-' . $name . '" style="border: 0 none; position: relative; top: 0ex; left: 10px; color: #aaa; height: 0px; overflow: visible;' . (empty($content) ? '' : 'display:none;') . '">' . $this->translator->translate($elementOptions['placeholder']) . '</div>';
}
return $placeHolder . sprintf('<div %s >%s</div>', $this->createAttributesString($attributes), $content);
return sprintf('<textarea %s>%s</textarea>', $this->createAttributesString($attributes), $escapeHtml($content));
} else {
return (string) $content;
}
}
示例13: render
public function render(ElementInterface $element)
{
$type = $element->getAttribute('type');
if ($type == 'multi_checkbox' || $type == "radio") {
$aOptions = $element->getValueOptions();
$aAtributes = $element->getOptions();
$aClasse = $element->getAttributes();
$aClasse = explode(" ", @$aClasse["class"]);
$sType = $type;
$selected = $element->getValue();
$disabled = $element->getAttribute("disabled");
foreach ($aOptions as $sKey => $aOption) {
if (is_scalar($aOption)) {
$aOption = array('label' => " " . $aOption, 'value' => $sKey);
}
$aOption['label_attributes'] = array();
$classe = "";
if (!in_array("not-bootstrap", $aClasse)) {
$classe = "btn btn-default ";
if ($type == "multi_checkbox") {
if (@in_array($sKey, $selected)) {
$classe .= "active";
}
} else {
if ($type == "radio") {
if ($sKey == $selected) {
$classe .= "active";
}
}
}
}
if (in_array("not-bootstrap", $aClasse)) {
$classe .= "not-bootstrap";
}
if ($disabled) {
$classe .= " disabled";
}
if (empty($aOption['label_attributes']['class'])) {
$aOption['label_attributes']['class'] = trim($classe);
} elseif (!preg_match('/(\\s|^)' . preg_quote($classe) . '(\\s|$)/', $aOption['label_attributes']['class'])) {
$aOption['label_attributes']['class'] .= trim(' ' . $classe);
}
if (isset($aAtributes['data'])) {
foreach ($aAtributes['data'] as $key => $value) {
$aOption['label_attributes']['data-' . $key] = $value[$sKey];
}
}
if ($disabled) {
if ($type == "multi_checkbox") {
if (@in_array($sKey, $selected)) {
$aOptions[$sKey] = $aOption;
} else {
unset($aOptions[$sKey]);
}
} else {
if ($type == "radio") {
if ($sKey == $selected) {
$aOptions[$sKey] = $aOption;
} else {
unset($aOptions[$sKey]);
}
}
}
} else {
$aOptions[$sKey] = $aOption;
}
}
$element->setValueOptions($aOptions);
if (!in_array("not-bootstrap", $aClasse)) {
return sprintf('<div><div class="btn-group" data-toggle="buttons">%s</div></div>', parent::render($element));
} else {
return sprintf('<div>%s</div>', parent::render($element));
}
}
return parent::render($element);
}