5

I have added a field as per Magento standard structure, hidden field appeared but value is not showing.

$fieldset->addField('entity_type_id', 'hidden', 
    array(
      'name'               => 'entity_type_id',
      'value'              => 11
    ));

NOTE : I have tried 'value' instead of 'values' but not working

Can anyone suggest how can I set the field value in Magento 2 admin form.

2 Answers 2

2
$this->setForm($form);

custom field with field value

$data=array('entity_type_id'=>11);   
$form->setValues($data);

NOTE : I got reference from this answer and it is working perfectly fine for me for hidden field as well for text field.

1

Try This :-

Reference :- vendor/magento/module-sales/Block/Adminhtml/Order/Status/NewStatus/Form.php

Line no. 40

$fieldset->addField('entity_type_id', 'hidden', 
   [
      'name' => 'entity_type_id',
      'value' => 11
   ]);
4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.