Oh snap! You are using an old version of browser. Update your browser to get new awesome features. Click for more details.

Magento add hidden field in admin form field


Hi Friend's

Add hidden field in admin form field and get value in controller. first add hidden field in form.php file

$form->addField('created_date', 'hidden',
array(
'name'      => 'created_date',
'label'     => 'created_date',
'class'     => 'required-entry',
'required'  => true,
'readonly'  => true,
));

Get hidden field value in controller file

$this->getRequest()->getPost('created_date');

3 comments

  1. Hi vithal, how do we set value for the hidden field?

    ReplyDelete
    Replies
    1. Hi Tùng Đào,

      You can put this code 'value' => 'Your value here'
      For Ex.

      $form->addField('created_date', 'hidden',
      array(
      'name' => 'created_date',
      'label' => 'created_date',
      'class' => 'required-entry',
      'required' => true,
      'readonly' => true,
      'value' => 'Your value here'
      ));

      Delete
  2. I haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. magento data entry

    ReplyDelete