16 abstract class AbstractMain extends \Magento\Backend\Block\Widget\Form\Generic
61 \
Magento\Framework\Data\FormFactory $formFactory,
62 \
Magento\Eav\Helper\Data $eavData,
64 \
Magento\Eav\Model\Adminhtml\System\
Config\Source\InputtypeFactory $inputTypeFactory,
68 $this->_eavData = $eavData;
69 $this->_yesnoFactory = $yesnoFactory;
70 $this->_inputTypeFactory = $inputTypeFactory;
95 if (
null === $this->_attribute) {
96 return $this->_coreRegistry->registry(
'entity_attribute');
112 $form = $this->_formFactory->create(
114 [
'data' => [
'id' =>
'edit_form',
'action' => $this->
getData(
'action'),
'method' =>
'post']]
117 $fieldset = $form->addFieldset(
'base_fieldset', [
'legend' =>
__(
'Attribute Properties')]);
119 if ($attributeObject->getAttributeId()) {
120 $fieldset->addField(
'attribute_id',
'hidden', [
'name' =>
'attribute_id']);
125 $yesno = $this->_yesnoFactory->create()->toOptionArray();
127 $labels = $attributeObject->getFrontendLabel();
132 'name' =>
'frontend_label[0]',
133 'label' =>
__(
'Default Label'),
134 'title' =>
__(
'Default label'),
136 'value' => is_array($labels) ? $labels[0] : $labels
140 $validateClass = sprintf(
141 'validate-code validate-length maximum-length-%d',
148 'name' =>
'attribute_code',
149 'label' =>
__(
'Attribute Code'),
150 'title' =>
__(
'Attribute Code'),
152 'This is used internally. Make sure you don\'t use spaces or more than %1 symbols.',
155 'class' => $validateClass,
164 'name' =>
'frontend_input',
165 'label' =>
__(
'Catalog Input Type for Store Owner'),
166 'title' =>
__(
'Catalog Input Type for Store Owner'),
168 'values' => $this->_inputTypeFactory->create()->toOptionArray()
176 'name' =>
'is_required',
177 'label' =>
__(
'Values Required'),
178 'title' =>
__(
'Values Required'),
184 'default_value_text',
187 'name' =>
'default_value_text',
188 'label' =>
__(
'Default Value'),
189 'title' =>
__(
'Default Value'),
190 'value' => $attributeObject->getDefaultValue()
195 'default_value_yesno',
198 'name' =>
'default_value_yesno',
199 'label' =>
__(
'Default Value'),
200 'title' =>
__(
'Default Value'),
202 'value' => $attributeObject->getDefaultValue()
206 $dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
208 'default_value_date',
211 'name' =>
'default_value_date',
212 'label' =>
__(
'Default Value'),
213 'title' =>
__(
'Default Value'),
214 'value' => $attributeObject->getDefaultValue(),
215 'date_format' => $dateFormat
220 'default_value_textarea',
223 'name' =>
'default_value_textarea',
224 'label' =>
__(
'Default Value'),
225 'title' =>
__(
'Default Value'),
226 'value' => $attributeObject->getDefaultValue()
234 'name' =>
'is_unique',
235 'label' =>
__(
'Unique Value'),
236 'title' =>
__(
'Unique Value (not shared with other products)'),
237 'note' =>
__(
'Not shared with other products.'),
246 'name' =>
'frontend_class',
247 'label' =>
__(
'Input Validation for Store Owner'),
248 'title' =>
__(
'Input Validation for Store Owner'),
249 'values' => $this->_eavData->getFrontendClasses($attributeObject->getEntityType()->getEntityTypeCode())
253 if ($attributeObject->getId()) {
254 $form->getElement(
'attribute_code')->setDisabled(1);
255 $form->getElement(
'frontend_input')->setDisabled(1);
256 if (!$attributeObject->getIsUserDefined()) {
257 $form->getElement(
'is_unique')->setDisabled(1);
261 $this->propertyLocker->lock($form);
264 return parent::_prepareForm();
274 $this->_eventManager->dispatch(
275 'adminhtml_block_eav_attribute_edit_form_init',
279 return parent::_initFormValues();
293 return $html . $jsScripts;
getData($key='', $index=null)
const ATTRIBUTE_CODE_MAX_LENGTH
setAttributeObject($attribute)
__construct(\Magento\Backend\Block\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, \Magento\Eav\Helper\Data $eavData, \Magento\Config\Model\Config\Source\YesnoFactory $yesnoFactory, \Magento\Eav\Model\Adminhtml\System\Config\Source\InputtypeFactory $inputTypeFactory, \Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker $propertyLocker, array $data=[])