本文整理汇总了PHP中Magento\Framework\Data\Form\Element\AbstractElement::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractElement::getId方法的具体用法?PHP AbstractElement::getId怎么用?PHP AbstractElement::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Data\Form\Element\AbstractElement
的用法示例。
在下文中一共展示了AbstractElement::getId方法的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: _isCollapseState
/**
* 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;
}
示例3: _isCollapseState
/**
* Return collapse state
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return bool
*/
protected function _isCollapseState($element)
{
$extra = $this->_authSession->getUser()->getExtra();
if (isset($extra['configState'][$element->getId()])) {
return $extra['configState'][$element->getId()];
}
$groupConfig = $element->getGroup();
if (!empty($groupConfig['expanded'])) {
return true;
}
return false;
}
示例4: addElement
/**
* 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;
}
示例5: prepareElementHtml
/**
* Prepare chooser element HTML
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element Form Element
* @return \Magento\Framework\Data\Form\Element\AbstractElement
*/
public function prepareElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$uniqId = $this->mathRandom->getUniqueHash($element->getId());
$sourceUrl = $this->getUrl('cms/page_widget/chooser', ['uniq_id' => $uniqId]);
$chooser = $this->getLayout()->createBlock('Magento\\Widget\\Block\\Adminhtml\\Widget\\Chooser')->setElement($element)->setConfig($this->getConfig())->setFieldsetId($this->getFieldsetId())->setSourceUrl($sourceUrl)->setUniqId($uniqId);
if ($element->getValue()) {
$page = $this->_pageFactory->create()->load((int) $element->getValue());
if ($page->getId()) {
$chooser->setLabel($this->escapeHtml($page->getTitle()));
}
}
$element->setData('after_element_html', $chooser->toHtml());
return $element;
}
示例6: prepareElementHtml
/**
* Prepare chooser element HTML
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element Form Element
* @return \Magento\Framework\Data\Form\Element\AbstractElement
*/
public function prepareElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$uniqId = $this->mathRandom->getUniqueHash($element->getId());
$sourceUrl = $this->getUrl('sales_rule/promo_quote/chooser', array('uniq_id' => $uniqId));
$chooser = $this->getLayout()->createBlock('Magento\\Widget\\Block\\Adminhtml\\Widget\\Chooser')->setElement($element)->setConfig($this->getConfig())->setFieldsetId($this->getFieldsetId())->setSourceUrl($sourceUrl)->setUniqId($uniqId);
if ($element->getValue()) {
$rule = $this->ruleFactory->create()->load((int) $element->getValue());
if ($rule->getId()) {
$chooser->setLabel($rule->getName());
}
}
$element->setData('after_element_html', $chooser->toHtml());
return $element;
}
示例7: prepareElementHtml
/**
* Prepare chooser element HTML
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element Form Element
* @return \Magento\Framework\Data\Form\Element\AbstractElement
*/
public function prepareElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$uniqId = $this->mathRandom->getUniqueHash($element->getId());
$sourceUrl = $this->getUrl('catalog/category_widget/chooser', ['uniq_id' => $uniqId, 'use_massaction' => false]);
$chooser = $this->getLayout()->createBlock('Magento\\Widget\\Block\\Adminhtml\\Widget\\Chooser')->setElement($element)->setConfig($this->getConfig())->setFieldsetId($this->getFieldsetId())->setSourceUrl($sourceUrl)->setUniqId($uniqId);
if ($element->getValue()) {
$value = explode('/', $element->getValue());
$categoryId = false;
if (isset($value[0]) && isset($value[1]) && $value[0] == 'category') {
$categoryId = $value[1];
}
if ($categoryId) {
$label = $this->_categoryFactory->create()->load($categoryId)->getName();
$chooser->setLabel($label);
}
}
$element->setData('after_element_html', $chooser->toHtml());
return $element;
}
示例8: prepareElementHtml
/**
* Prepare chooser element HTML
*
* @param AbstractElement $element Form Element
* @return AbstractElement
*/
public function prepareElementHtml(AbstractElement $element)
{
$uniqId = $this->mathRandom->getUniqueHash($element->getId());
$sourceUrl = $this->getUrl('catalog/product_widget/chooser', ['uniq_id' => $uniqId, 'use_massaction' => false]);
$chooser = $this->getLayout()->createBlock('Magento\\Widget\\Block\\Adminhtml\\Widget\\Chooser')->setElement($element)->setConfig($this->getConfig())->setFieldsetId($this->getFieldsetId())->setSourceUrl($sourceUrl)->setUniqId($uniqId);
if ($element->getValue()) {
$value = explode('/', $element->getValue());
$productId = false;
if (isset($value[0]) && isset($value[1]) && $value[0] == 'product') {
$productId = $value[1];
}
$categoryId = isset($value[2]) ? $value[2] : false;
$label = '';
if ($categoryId) {
$label = $this->_resourceCategory->getAttributeRawValue($categoryId, 'name', $this->_storeManager->getStore()) . '/';
}
if ($productId) {
$label .= $this->_resourceProduct->getAttributeRawValue($productId, 'name', $this->_storeManager->getStore());
}
$chooser->setLabel($label);
}
$element->setData('after_element_html', $chooser->toHtml());
return $element;
}
示例9: _addAdditionalFormElementData
/**
* Add additional data to form element
*
* @param AbstractElement $element
* @return $this
*/
protected function _addAdditionalFormElementData(AbstractElement $element)
{
switch ($element->getId()) {
case 'email':
$element->setRequired(0);
$element->setClass('validate-email');
break;
}
return $this;
}
示例10: addElementToCollection
/**
* @param AbstractElement $element
* @return $this
*/
public function addElementToCollection($element)
{
$this->_elementsIndex[$element->getId()] = $element;
$this->_allElements->add($element);
return $this;
}
示例11: _addAdditionalFormElementData
/**
* Add additional data to form element
*
* @param AbstractElement $element
* @return $this
*/
protected function _addAdditionalFormElementData(AbstractElement $element)
{
if ($element->getId() == 'region_id') {
$element->setNoDisplay(true);
}
return $this;
}
示例12: _getAdditionalElementHtml
/**
* Custom additional element html
*
* @param AbstractElement $element
* @return string
*/
protected function _getAdditionalElementHtml($element)
{
// Add name attribute to checkboxes that correspond to multiselect elements
$nameAttributeHtml = $element->getExtType() === 'multiple' ? 'name="' . $element->getId() . '_checkbox"' : '';
$elementId = $element->getId();
$checkboxLabel = __('Change');
$html = <<<HTML
<span class="attribute-change-checkbox">
<label>
<input type="checkbox" {$nameAttributeHtml} onclick="toogleFieldEditMode(this, '{$elementId}')" />
{$checkboxLabel}
</label>
</span>
<script>initDisableFields("{$elementId}")</script>
HTML;
if ($elementId === 'weight') {
$html .= <<<HTML
<script>jQuery(function(\$) {
\$('#weight_and_type_switcher, label[for=weight_and_type_switcher]').hide();
});</script>
HTML;
}
return $html;
}
示例13: _isCollapseState
/**
* Collapsed or expanded fieldset when page loaded?
*
* @param AbstractElement $element
* @return bool
*/
protected function _isCollapseState($element)
{
if ($element->getExpanded() || $element->getForm() && $element->getForm()->getElements()->count() === 1) {
return true;
}
$extra = $this->_authSession->getUser()->getExtra();
if (isset($extra['configState'][$element->getId()])) {
return $extra['configState'][$element->getId()];
}
return $this->isCollapsedDefault;
}
示例14: _getAdditionalElementHtml
/**
* Custom additional element html
*
* @param AbstractElement $element
* @return string
*/
protected function _getAdditionalElementHtml($element)
{
// Add name attribute to checkboxes that correspond to multiselect elements
$nameAttributeHtml = $element->getExtType() === 'multiple' ? 'name="' . $element->getId() . '_checkbox"' : '';
$elementId = $element->getId();
$dataAttribute = "data-disable='{$elementId}'";
$dataCheckboxName = "toggle_" . "{$elementId}";
$checkboxLabel = __('Change');
$html = <<<HTML
<span class="attribute-change-checkbox">
<input type="checkbox" id="{$dataCheckboxName}" name="{$dataCheckboxName}" class="checkbox" {$nameAttributeHtml} onclick="toogleFieldEditMode(this, '{$elementId}')" {$dataAttribute} />
<label class="label" for="{$dataCheckboxName}">
{$checkboxLabel}
</label>
</span>
HTML;
if ($elementId === 'weight') {
$html .= <<<HTML
<script>require(['Magento_Catalog/js/product/weight-handler'], function (weightHandle) {
weightHandle.hideWeightSwitcher();
});</script>
HTML;
}
return $html;
}
示例15: _getAdditionalElementHtml
/**
* Custom additional element html
*
* @param AbstractElement $element
* @return string
*/
protected function _getAdditionalElementHtml($element)
{
// Add name attribute to checkboxes that correspond to multiselect elements
$nameAttributeHtml = $element->getExtType() === 'multiple' ? 'name="' . $element->getId() . '_checkbox"' : '';
$elementId = $element->getId();
$dataAttribute = "data-disable='{$elementId}'";
$dataCheckboxName = "toggle_" . "{$elementId}";
$checkboxLabel = __('Change');
$html = <<<HTML
<span class="attribute-change-checkbox">
<input type="checkbox" id="{$dataCheckboxName}" name="{$dataCheckboxName}" class="checkbox" {$nameAttributeHtml} onclick="toogleFieldEditMode(this, '{$elementId}')" {$dataAttribute} />
<label class="label" for="{$dataCheckboxName}">
{$checkboxLabel}
</label>
</span>
HTML;
if ($elementId === 'weight') {
$html .= <<<HTML
<script type="text/javascript">require(["jquery"],function(\$) {
\$('#weight_and_type_switcher, label[for=weight_and_type_switcher]').hide();
});</script>
HTML;
}
return $html;
}