4

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.

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
   ]);
| improve this answer | |
  • Hi @RkRathod it's not working. Value is not displaying in inspect element. – Aditya Shah Sep 9 '19 at 11:54
  • +1 for the efforts. – Aditya Shah Sep 9 '19 at 11:54
  • if I add value using inspect element, even tho it is not showing in text field :D – Aditya Shah Sep 9 '19 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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