/** * @codeCoverageIgnore */ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) { $originalData = $element->getOriginalData(); $label = $originalData['button_label']; $this->addData(['button_label' => __($label), 'button_url' => $this->getUrl('magewondersmtp/email/test'), 'html_id' => $element->getHtmlId()]); return $this->_toHtml(); }
/** * Return header title part of html for payment solution * * @param \Magento\Framework\Data\Form\Element\AbstractElement $element * * @return string * @SuppressWarnings(PHPMD.NPathComplexity) */ protected function _getHeaderTitleHtml($element) { $html = '<div class="config-heading meli" ><div class="heading"><strong id="meli-logo">' . $element->getLegend(); $html .= '</strong></div>'; $html .= '<div class="button-container meli-cards"><button type="button"' . ' class="meli-payment-btn action-configure button' . '" id="' . $element->getHtmlId() . '-head" onclick="Fieldset.toggleCollapse(\'' . $element->getHtmlId() . '\', \'' . $this->getUrl('*/*/state') . '\'); return false;"><span class="state-closed">' . __('Configure') . '</span><span class="state-opened">' . __('Close') . '</span></button></div></div>'; return $html; }
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) { $originalData = $element->getOriginalData(); $buttonLabel = !empty($originalData['button_label']) ? $originalData['button_label'] : $this->_saveButtonLabel; $this->addData(['button_label' => __($buttonLabel), 'html_id' => $element->getHtmlId(), 'ajax_url' => $this->_urlBuilder->getUrl('seo/system_config_robot/save')]); return $this->_toHtml(); }
/** * @param AbstractElement $element * @return string */ protected function _getElementHtml(AbstractElement $element) { $element->unsScope(); $element->unsCanUseWebsiteValue(); $element->unsCanUseDefaultValue(); return $this->getDbStatus(); }
/** * @param mixed $expanded * @param int $expected * @dataProvider isCollapseStateDataProvider */ public function testIsCollapseState($expanded, $expected) { $this->_user->setExtra(['configState' => []]); $this->_element->setGroup(isset($expanded) ? ['expanded' => $expanded] : []); $html = $this->_model->render($this->_element); $this->assertContains('<input id="' . $this->_element->getHtmlId() . '-state" name="config_state[' . $this->_element->getId() . ']" type="hidden" value="' . $expected . '" />', $html); }
/** * @covers \Magento\Cms\Block\Adminhtml\Block\Widget\Chooser::prepareElementHtml * @param string $elementValue * @param integer|null $modelBlockId * * @dataProvider prepareElementHtmlDataProvider */ public function testPrepareElementHtml($elementValue, $modelBlockId) { $elementId = 1; $uniqId = '126hj4h3j73hk7b347jhkl37gb34'; $sourceUrl = 'cms/block_widget/chooser/126hj4h3j73hk7b347jhkl37gb34'; $config = ['key1' => 'value1']; $fieldsetId = 2; $html = 'some html'; $title = 'some title'; $this->this->setConfig($config); $this->this->setFieldsetId($fieldsetId); $this->elementMock->expects($this->atLeastOnce())->method('getId')->willReturn($elementId); $this->mathRandomMock->expects($this->atLeastOnce())->method('getUniqueHash')->with($elementId)->willReturn($uniqId); $this->urlBuilderMock->expects($this->atLeastOnce())->method('getUrl')->with('cms/block_widget/chooser', ['uniq_id' => $uniqId])->willReturn($sourceUrl); $this->layoutMock->expects($this->atLeastOnce())->method('createBlock')->with('Magento\\Widget\\Block\\Adminhtml\\Widget\\Chooser')->willReturn($this->chooserMock); $this->chooserMock->expects($this->atLeastOnce())->method('setElement')->with($this->elementMock)->willReturnSelf(); $this->chooserMock->expects($this->atLeastOnce())->method('setConfig')->with($config)->willReturnSelf(); $this->chooserMock->expects($this->atLeastOnce())->method('setFieldsetId')->with($fieldsetId)->willReturnSelf(); $this->chooserMock->expects($this->atLeastOnce())->method('setSourceUrl')->with($sourceUrl)->willReturnSelf(); $this->chooserMock->expects($this->atLeastOnce())->method('setUniqId')->with($uniqId)->willReturnSelf(); $this->elementMock->expects($this->atLeastOnce())->method('getValue')->willReturn($elementValue); $this->blockFactoryMock->expects($this->any())->method('create')->willReturn($this->modelBlockMock); $this->modelBlockMock->expects($this->any())->method('load')->with($elementValue)->willReturnSelf(); $this->modelBlockMock->expects($this->any())->method('getId')->willReturn($modelBlockId); $this->modelBlockMock->expects($this->any())->method('getTitle')->willReturn($title); $this->chooserMock->expects($this->any())->method('setLabel')->with($title)->willReturnSelf(); $this->chooserMock->expects($this->atLeastOnce())->method('toHtml')->willReturn($html); $this->elementMock->expects($this->atLeastOnce())->method('setData')->with('after_element_html', $html)->willReturnSelf(); $this->assertEquals($this->elementMock, $this->this->prepareElementHtml($this->elementMock)); }
/** * @param AbstractElement $element * @return string */ public function render(AbstractElement $element) { if ($element->getRule() && $element->getRule()->getActions()) { return $element->getRule()->getActions()->asHtmlRecursive(); } return ''; }
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) { $element->setValue(0); $element->setDisabled('disabled'); $element->setValues([['label' => __('Disabled - Coming Soon...'), 'value' => '0']]); return $element->getElementHtml(); }
protected function _renderScopeLabel(\Magento\Framework\Data\Form\Element\AbstractElement $element) { $html = '<td class="scope-label" style="display:none;">'; $html .= $element->getTooltip(); $html .= '</td>'; return $html; }
/** * {@inheritdoc} */ protected function _getElementHtml(AbstractElement $element) { $originalData = $element->getOriginalData(); $buttonLabel = $originalData['button_label']; $this->addData(['button_label' => __($buttonLabel), 'html_id' => $element->getHtmlId(), 'ajax_url' => $this->_urlBuilder->getUrl('searchsphinx/command/' . $this->getAction())]); return $this->_toHtml(); }
/** * @dataProvider isPaymentEnabledDataProvider */ public function testIsPaymentEnabled($groupConfig, $expected) { $this->_element->setGroup($groupConfig); $this->_backendConfig->expects($this->any())->method('getConfigDataValue')->will($this->returnValueMap([[self::CONFIG_PATH_ACTIVE, null, null, '1'], [self::CONFIG_PATH_NOT_ACTIVE, null, null, '0']])); $html = $this->_model->render($this->_element); $this->assertContains($expected, $html); }
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) { $originalData = $element->getOriginalData(); $label = $originalData['button_label']; $this->addData(array('button_label' => __($label), 'button_url' => $this->authorizeRequestUrl(), 'html_id' => $element->getHtmlId())); return $this->_toHtml(); }
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) { $element->setData('after_element_html', "<script src='//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'></script><script type=\\'text/javascript\\'>"); // Set up additional JavaScript for our validation using jQuery. $element->setData('after_element_html', "\n\t jQuery.noConflict();\n jQuery(document).ready(function() {\n\t\t\t\tjQuery('#connector_data_mapping_enterprise_data-head').parent().hide();\n });\n </script>"); return parent::_getElementHtml($element); }
/** * Get the button and scripts contents * * @param \Magento\Framework\Data\Form\Element\AbstractElement $element * @return string */ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) { $originalData = $element->getOriginalData(); $buttonLabel = !empty($originalData['button_label']) ? $originalData['button_label'] : $this->_vatButtonLabel; $this->addData(['button_label' => __($buttonLabel), 'html_id' => $element->getHtmlId()]); return $this->_toHtml(); }
/** * @param AbstractElement $element * @return string */ public function render(AbstractElement $element) { if (!$element instanceof Select || empty($element->getData('values'))) { return ''; } return parent::render($element); }
/** * Return header comment part of html for fieldset * * @param \Magento\Framework\Data\Form\Element\AbstractElement $element * @return string */ protected function _getHeaderCommentHtml($element) { $beforeDiv = '<div style="padding:10px;background-color:#fff;border:1px solid #ddd;margin-bottom:7px;">'; $afterDiv = '</div>'; $synch = __('Click here to <a href="%1">Synchronize</a> with ShipperHQ.', $this->getUrl('shipperhq/synchronize/index')); $element->getComment() ? $comment = $element->getComment() : ($comment = ''); $html = $beforeDiv . '<table> <tr> <td style="vertical-align:bottom"> <b>ShipperHQ installed version ' . $this->getModuleVersion() . '</b> </td> </tr> <tr> <td colspan="3"> <p>' . $comment . '</p> </td> </tr> <tr> <td colspan="3"> <p>' . $synch . '</p> </td> </tr> </table>' . $afterDiv; return $html; }
/** * @param AbstractElement $element * @return string */ protected function _getElementHtml(AbstractElement $element) { $extensionVersion = $this->_helper->getExtensionVersion(); $versionLabel = sprintf('<a href="%s" title="Easy Template Path Hints for Magento 2" target="_blank">%s</a>', self::EXTENSION_URL, $extensionVersion); $element->setValue($versionLabel); return $element->getValue(); }
/** * @param AbstractElement $element * @return string */ public function render(AbstractElement $element) { $countryId = false; $isRegionRequired = false; if ($country = $element->getForm()->getElement('country_id')) { $countryId = $country->getValue(); $isRegionRequired = $this->_directoryHelper->isRegionRequired($countryId); } $html = '<div class="field field-region ' . ($isRegionRequired ? 'required' : '') . '">' . "\n"; $regionCollection = false; if ($countryId) { if (!isset(self::$_regionCollections[$countryId])) { self::$_regionCollections[$countryId] = $this->_countryFactory->create()->setId($countryId)->getLoadedRegionCollection()->toOptionArray(); } $regionCollection = self::$_regionCollections[$countryId]; } $regionId = intval($element->getForm()->getElement('region_id')->getValue()); $htmlAttributes = $element->getHtmlAttributes(); foreach ($htmlAttributes as $key => $attribute) { if ('type' === $attribute) { unset($htmlAttributes[$key]); break; } } // Output two elements - for 'region' and for 'region_id'. // Two elements are needed later upon form post - to properly set data to address model, // otherwise old value can be left in region_id attribute and saved to DB. // Depending on country selected either 'region' (input text) or 'region_id' (selectbox) is visible to user $regionHtmlName = $element->getName(); $regionIdHtmlName = str_replace('region', 'region_id', $regionHtmlName); $regionHtmlId = $element->getHtmlId(); $regionIdHtmlId = str_replace('region', 'region_id', $regionHtmlId); if ($isRegionRequired) { $element->addClass('required-entry'); } if ($regionCollection && count($regionCollection) > 0) { $elementClass = $element->getClass(); $html .= '<label class="label" for="' . $regionIdHtmlId . '"><span>' . $element->getLabel() . '</span>' . '</label>'; $html .= '<div class="control">'; $html .= '<select id="' . $regionIdHtmlId . '" name="' . $regionIdHtmlName . '" ' . $element->serialize($htmlAttributes) . '>' . "\n"; foreach ($regionCollection as $region) { $selected = $regionId == $region['value'] ? ' selected="selected"' : ''; $regionVal = 0 == $region['value'] ? '' : (int) $region['value']; $html .= '<option value="' . $regionVal . '"' . $selected . '>' . $this->_escaper->escapeHtml(__($region['label'])) . '</option>'; } $html .= '</select>' . "\n"; $html .= '<input type="hidden" name="' . $regionHtmlName . '" id="' . $regionHtmlId . '" value=""/>'; $html .= '</div>'; $element->setClass($elementClass); } else { $html .= '<label class="label" for="' . $regionHtmlId . '"><span>' . $element->getLabel() . '</span></label>'; $html .= '<div class="control">'; $html .= '<input id="' . $regionHtmlId . '" name="' . $regionHtmlName . '" value="' . $element->getEscapedValue() . '" ' . $element->serialize($htmlAttributes) . "/>" . "\n"; $html .= '<input type="hidden" name="' . $regionIdHtmlName . '" id="' . $regionIdHtmlId . '" value=""/>'; $html .= '</div>' . "\n"; } $html .= '</div>' . "\n"; return $html; }
/** * Get the button and scripts contents. * * @param \Magento\Framework\Data\Form\Element\AbstractElement $element * * @return string */ public function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) { $originalData = $element->getOriginalData(); $buttonLabel = !empty($originalData['button_label']) ? $originalData['button_label'] : $this->buttonLabel; $url = $this->_urlBuilder->getUrl('dotdigitalgroup_email/addressbook/save'); $this->addData(['button_label' => __($buttonLabel), 'html_id' => $element->getHtmlId(), 'ajax_url' => $url]); return $this->_toHtml(); }
/** * Retrieve label for the inheritance checkbox * * @SuppressWarnings(PHPMD.CamelCaseMethodName) * * @param \Magento\Framework\Data\Form\Element\AbstractElement $element The form element * * @return string */ protected function _getInheritCheckboxLabel(\Magento\Framework\Data\Form\Element\AbstractElement $element) { $checkboxLabel = __('Use Default'); if ($element->getCanUseContainerValue()) { $checkboxLabel = __('Use Container'); } return $checkboxLabel; }
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) { $id = $element->getHtmlId(); $html = '<tr id="row_' . $id . '">'; $html .= '<td class="label">' . __('Module Version') . '</td><td class="value">' . $this->getModuleVersion() . '</td><td class="scope-label"></td>'; $html .= '</tr>'; return $html; }
/** * @param AbstractElement $element * @return string */ protected function _getElementHtml(AbstractElement $element) { $extensionVersion = $this->_helper->getExtensionVersion(); $extensionTitle = 'Custom Shipping'; $versionLabel = sprintf('<a href="%s" title="%s" target="_blank">%s</a>', self::EXTENSION_URL, $extensionTitle, $extensionVersion); $element->setValue($versionLabel); return $element->getValue(); }
/** * Render fieldset html * * @param \Magento\Framework\Data\Form\Element\AbstractElement $element * @return string */ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) { $elementOriginalData = $element->getOriginalData(); if (isset($elementOriginalData['help_link'])) { $this->setHelpLink($elementOriginalData['help_link']); } return $this->toHtml(); }
/** * Return collapse state * * @param AbstractElement $element * @return string|true */ protected function _isCollapseState($element) { $extra = $this->_authSession->getUser()->getExtra(); if (isset($extra['configState'][$element->getId()])) { return $extra['configState'][$element->getId()]; } return true; }
/** * Prepare wysiwyg element HTML * * @param AbstractElement $element Form Element * @return AbstractElement */ public function prepareElementHtml(AbstractElement $element) { /* @var $fieldset \Magento\Framework\Data\Form\Element\Fieldset */ $fieldset = $element->getForm()->getElement($this->getFieldsetId()); $widgetValues = $this->getLayout()->getBlock('easytabs.tab.options')->getWidgetValues(); $fieldset->addField('widget_content', 'editor', ['name' => 'parameters[widget_content]', 'label' => __('Content'), 'title' => __('Content'), 'style' => 'height:36em', 'required' => true, 'config' => $this->wysiwygConfig->getConfig(), 'value' => $widgetValues['widget_content']]); return $element; }
/** * Render given element (return html of element) * * @param \Magento\Framework\Data\Form\Element\AbstractElement $element The element * * @return string */ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) { if ($this->getValues()) { $element->setValue($this->getValues()); } $this->setElement($element); return $this->toHtml(); }
public function testRender() { $rule = $this->getMockBuilder('Magento\\Rule\\Model\\AbstractModel')->setMethods(['getConditions', '__sleep', '__wakeup'])->disableOriginalConstructor()->getMockForAbstractClass(); $conditions = $this->getMock('\\Magento\\Rule\\Model\\Condition\\Combine', ['asHtmlRecursive'], [], '', false); $this->_element->expects($this->any())->method('getRule')->will($this->returnValue($rule)); $rule->expects($this->any())->method('getConditions')->will($this->returnValue($conditions)); $conditions->expects($this->once())->method('asHtmlRecursive')->will($this->returnValue('conditions html')); $this->assertEquals('conditions html', $this->conditions->render($this->_element)); }
/** * Run test for render method * * @return void */ public function testRender() { $formMock = $this->getMockBuilder('Magento\\Framework\\Data\\Form')->setMethods(['getFieldNameSuffix'])->disableOriginalConstructor()->getMock(); $this->elementMock->expects($this->any())->method('getHtmlId')->willReturn('test-html-id'); $this->elementMock->expects($this->once())->method('getTooltip')->willReturn(''); $this->elementMock->expects($this->any())->method('getForm')->willReturn($formMock); $formMock->expects($this->any())->method('getFieldNameSuffix')->willReturn(''); $this->assertContains(self::EXPECTED_ATTRIBUTE, $this->abstractEnable->render($this->elementMock)); }
/** * Add form element * * @param AbstractElement $element * @param bool $after * @return Form */ public function addElement(AbstractElement $element, $after = false) { if ($this->getForm()) { $this->getForm()->checkElementId($element->getId()); $this->getForm()->addElementToCollection($element); } parent::addElement($element, $after); return $this; }
/** * @param AbstractElement $element * @return string */ protected function _getElementHtml(AbstractElement $element) { $_days = []; for ($i = 1; $i <= 31; $i++) { $_days[$i] = $i < 10 ? '0' . $i : $i; } $_daysHtml = $element->setStyle('width:50px;')->setValues($_days)->getElementHtml(); return $_daysHtml; }