本文整理汇总了PHP中Magento\Framework\Data\Form\Element\AbstractElement::getHtmlId方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractElement::getHtmlId方法的具体用法?PHP AbstractElement::getHtmlId怎么用?PHP AbstractElement::getHtmlId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Data\Form\Element\AbstractElement
的用法示例。
在下文中一共展示了AbstractElement::getHtmlId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIsCollapseState
/**
* @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);
}
示例2: render
/**
* Output the region element and javasctipt that makes it dependent from country element
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
if ($country = $element->getForm()->getElement('country_id')) {
$countryId = $country->getValue();
} else {
return $element->getDefaultHtml();
}
$regionId = $element->getForm()->getElement('region_id')->getValue();
$html = '<div class="field field-state required">';
$element->setClass('input-text');
$element->setRequired(true);
$html .= $element->getLabelHtml() . '<div class="control">';
$html .= $element->getElementHtml();
$selectName = str_replace('region', 'region_id', $element->getName());
$selectId = $element->getHtmlId() . '_id';
$html .= '<select id="' . $selectId . '" name="' . $selectName . '" class="select required-entry" style="display:none">';
$html .= '<option value="">' . __('Please select') . '</option>';
$html .= '</select>';
$html .= '<script>' . "\n";
$html .= 'require(["prototype", "mage/adminhtml/form"], function(){';
$html .= '$("' . $selectId . '").setAttribute("defaultValue", "' . $regionId . '");' . "\n";
$html .= 'new regionUpdater("' . $country->getHtmlId() . '", "' . $element->getHtmlId() . '", "' . $selectId . '", ' . $this->_directoryHelper->getRegionJson() . ');' . "\n";
$html .= '});';
$html .= '</script>' . "\n";
$html .= '</div></div>' . "\n";
return $html;
}
示例3: _getHeaderTitleHtml
/**
* 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;
}
示例4: render
/**
* Checkbox render function
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
/** @var \Magento\Framework\Data\Form\Element\Checkbox $checkbox */
$checkbox = $this->_elementFactory->create('checkbox', array('data' => $element->getData()));
$checkbox->setForm($element->getForm());
$elementHtml = sprintf('<div class="field no-label field-%s with-note">' . '<div class="control">' . '<div class="nested">' . '<div class="field choice"> %s' . '<label class="label" for="%s">%s</label>' . '<p class="note">%s</p>' . '</div>' . '</div>' . '</div>' . '</div>', $element->getHtmlId(), $checkbox->getElementHtml(), $element->getHtmlId(), $element->getLabel(), $element->getNote());
return $elementHtml;
}
示例5: testGetHtmlId
/**
* @covers \Magento\Framework\Data\Form\Element\AbstractElement::getHtmlId()
*/
public function testGetHtmlId()
{
$htmlIdPrefix = '--';
$htmlIdSuffix = ']]';
$htmlId = 'some_id';
$formMock = $this->getMock('Magento\\Framework\\Data\\Form\\AbstractForm', ['getHtmlIdPrefix', 'getHtmlIdSuffix'], [], '', false);
$formMock->expects($this->any())->method('getHtmlIdPrefix')->will($this->returnValue($htmlIdPrefix));
$formMock->expects($this->any())->method('getHtmlIdSuffix')->will($this->returnValue($htmlIdSuffix));
$this->_model->setId($htmlId);
$this->_model->setForm($formMock);
$this->assertEquals($htmlIdPrefix . $htmlId . $htmlIdSuffix, $this->_model->getHtmlId());
}
示例6: _getElementHtml
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$html = '';
if ($element->getBeforeElementHtml() && $element->getBeforeElementHtml() != '') {
$html .= '<label class="addbefore" for="' . $element->getHtmlId() . '">' . $element->getBeforeElementHtml() . '</label>';
}
$html .= '<input id="' . $element->getHtmlId() . '" name="' . $element->getName() . '" ' . ' value="0" type="hidden"/>';
if ($element->getAfterElementJs() && $element->getAfterElementJs() != '') {
$html .= $element->getAfterElementJs();
}
if ($element->getAfterElementHtml() && $element->getAfterElementHtml() != '') {
$html .= '<label class="addafter" for="' . $element->getHtmlId() . '">' . $element->getAfterElementHtml() . '</label>';
}
return $html;
}
示例7: _getElementHtml
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();
}
示例8: render
/**
* @param AbstractElement $element
* @return string
*/
public function render(AbstractElement $element)
{
$html = '<div class="field field-' . $element->getHtmlId() . '">';
$html .= $element->getLabelHtml();
$html .= '<div class="control">' . $element->getElementHtml();
$html .= '<div class="nested">';
$html .= '<div class="field choice">';
$html .= '<label for="account-send-pass" class="addbefore"><span>' . __('or ') . '</span></label>';
$html .= '<input type="checkbox" id="account-send-pass" name="' . $element->getName() . '" value="auto" onclick="setElementDisable(\'' . $element->getHtmlId() . '\', this.checked)" />';
$html .= '<label class="label" for="account-send-pass"><span>' . __(' Send auto-generated password') . '</span></label>';
$html .= '</div>' . "\n";
$html .= '</div>' . "\n";
$html .= '</div>' . "\n";
$html .= '</div>' . "\n";
return $html;
}
示例9: _getElementHtml
/**
* 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();
}
示例10: _getElementHtml
/**
* @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();
}
示例11: _getElementHtml
/**
* {@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();
}
示例12: _getElementHtml
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();
}
示例13: render
/**
* @param AbstractElement $element
* @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
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;
}
示例14: _getElementHtml
/**
* 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();
}
示例15: render
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;
}