예제 #1
0
 public function testGetLockedFields()
 {
     $this->_entityType->expects($this->once())->method('getEntityTypeCode')->will($this->returnValue('test_code1/test_code2'));
     $this->_attribute->expects($this->once())->method('getEntityType')->will($this->returnValue($this->_entityType));
     $this->_attribute->expects($this->once())->method('getAttributeCode')->will($this->returnValue('test_code'));
     $data = ['test_code1' => ['test_code2' => ['attributes' => ['test_code' => ['test_code1' => 'test_code1']]]]];
     $this->_model->merge($data);
     $result = $this->_model->getLockedFields($this->_attribute);
     $this->assertEquals(['test_code1' => 'test_code1'], $result);
 }
 /**
  * @param \Magento\Framework\Data\Form $form
  * @return void
  */
 public function lock(\Magento\Framework\Data\Form $form)
 {
     /** @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attributeObject */
     $attributeObject = $this->registry->registry('entity_attribute');
     if ($attributeObject->getId()) {
         foreach ($this->attributeConfig->getLockedFields($attributeObject) as $field) {
             if ($element = $form->getElement($field)) {
                 $element->setDisabled(1);
                 $element->setReadonly(1);
             }
         }
     }
 }
예제 #3
0
 /**
  * This method is called before rendering HTML
  *
  * @return $this
  */
 protected function _beforeToHtml()
 {
     parent::_beforeToHtml();
     $attributeObject = $this->getAttributeObject();
     if ($attributeObject->getId()) {
         $form = $this->getForm();
         foreach ($this->_attributeConfig->getLockedFields($attributeObject) as $field) {
             if ($element = $form->getElement($field)) {
                 $element->setDisabled(1);
                 $element->setReadonly(1);
             }
         }
     }
     return $this;
 }