/**
  * Verify that hidden input is present in multiselect
  *
  * @covers \Magento\Framework\Data\Form\Element\Multiselect::getElementHtml
  */
 public function testHiddenFieldPresentInMultiSelect()
 {
     $this->_model->setDisabled(true);
     $this->_model->setCanBeEmpty(true);
     $elementHtml = $this->_model->getElementHtml();
     $this->assertContains('<input type="hidden"', $elementHtml);
 }
Example #2
0
 /**
  * @return string
  */
 public function getElementHtml()
 {
     $elementAttributeHtml = '';
     if ($this->getReadonly()) {
         $elementAttributeHtml = $elementAttributeHtml . ' readonly="readonly"';
     }
     if ($this->getDisabled()) {
         $elementAttributeHtml = $elementAttributeHtml . ' disabled="disabled"';
     }
     $html = '<select onchange="toggleApplyVisibility(this)"' . $elementAttributeHtml . '>' . '<option value="0">' . $this->getModeLabels('all') . '</option>' . '<option value="1" ' . ($this->getValue() == null ? '' : 'selected') . '>' . $this->getModeLabels('custom') . '</option>' . '</select><br /><br />';
     $html .= parent::getElementHtml();
     return $html;
 }
 /**
  * Retrieve HTML markup of the element
  *
  * @return string
  */
 public function getElementHtml()
 {
     $html = parent::getElementHtml();
     $selectConfig = $this->getData('select_config');
     if ($this->getData('disabled')) {
         $selectConfig['is_entity_editable'] = false;
     }
     $elementJsClass = self::DEFAULT_ELEMENT_JS_CLASS;
     if ($this->getData('element_js_class')) {
         $elementJsClass = $this->getData('element_js_class');
     }
     $selectConfigJson = \Zend_Json::encode($selectConfig);
     $jsObjectName = $this->getJsObjectName();
     $html .= '<script type="text/javascript">' . '/*<![CDATA[*/' . '(function($) { $().ready(function () { ' . "var {$jsObjectName} = new {$elementJsClass}({$selectConfigJson}); " . "{$jsObjectName}.init(); }); })(jQuery);" . '/*]]>*/' . '</script>';
     return $html;
 }
Example #4
0
 /**
  * Retrieve HTML markup of the element
  *
  * @return string
  */
 public function getElementHtml()
 {
     $html = parent::getElementHtml();
     $selectConfig = $this->getData('select_config');
     if ($this->getData('disabled')) {
         $selectConfig['is_entity_editable'] = false;
     }
     $elementJsClass = self::DEFAULT_ELEMENT_JS_CLASS;
     if ($this->getData('element_js_class')) {
         $elementJsClass = $this->getData('element_js_class');
     }
     $selectConfigJson = \Zend_Json::encode($selectConfig);
     $jsObjectName = $this->getJsObjectName();
     // TODO: TaxRateEditableMultiselect should be moved to a static .js module.
     $html .= "\n                <script type='text/javascript'>\n                require([\n                    'jquery',\n                    'jquery/ui'\n                ], function( \$ ){\n\n                    function isResolved(){\n                        return typeof window['{$elementJsClass}'] !== 'undefined'; \n                    }\n\n                    function init(){\n                        var {$jsObjectName} = new {$elementJsClass}({$selectConfigJson});\n                        \n                        {$jsObjectName}.init();\n                    }\n\n                    function check( tries, delay ){\n                        if( isResolved() ){\n                            init();\n                        }\n                        else if( tries-- ){\n                            setTimeout( check.bind(this, tries, delay), delay);\n                        }\n                        else{\n                            console.warn( 'Unable to resolve dependency: {$elementJsClass}' );\n                        }\n                    }\n\n                   check(8, 500);\n\n                });\n                </script>";
     return $html;
 }
 /**
  * Retrieve Element HTML fragment
  *
  * @return string
  */
 public function getElementHtml()
 {
     $elementDisabled = $this->getDisabled() == 'disabled';
     $disabled = false;
     if (!$this->getValue() || $elementDisabled) {
         $this->setData('disabled', 'disabled');
         $disabled = true;
     }
     $html = parent::getElementHtml();
     $htmlId = 'use_config_' . $this->getHtmlId();
     $html .= '<input id="' . $htmlId . '" name="use_config[]" value="' . $this->getId() . '"';
     $html .= $disabled ? ' checked="checked"' : '';
     if ($this->getReadonly() || $elementDisabled) {
         $html .= ' disabled="disabled"';
     }
     $html .= ' onclick="toggleValueElements(this, this.parentNode);" class="checkbox" type="checkbox" />';
     $html .= ' <label for="' . $htmlId . '" class="normal">' . __('Use All Available Attributes') . '</label>';
     $html .= '<script>require(["prototype"], function(){toggleValueElements($(\'' . $htmlId . '\'), $(\'' . $htmlId . '\').parentNode);});</script>';
     return $html;
 }
Example #6
0
 /**
  * @return string
  */
 public function getElementHtml()
 {
     $this->setSize($this->calculateSize());
     return parent::getElementHtml();
 }