Magento – How to set hidden field with value in Admin html – Magento 2

adminformadminhtmlmagento2magento2.2.8

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.

Best Answer

$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.

Related Topic