Skip to content

Commit

Permalink
New event "init_form_values_after" after data set on a form (#1485)
Browse files Browse the repository at this point in the history
* New event "init_form_values_after" after data set on a form

Magento does not have a common event after data is set on a form.
This new event allows us to change the form, the elements and the values once data is entered, giving full flexibility.
I needed this event in a special case where I needed to change the options of a select, to include the current value that was not in the existing options list.
There was no other way to do this without overriding many forms 1 by 1.

* Update app/code/core/Mage/Adminhtml/Block/Widget/Form.php

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>
  • Loading branch information
woutersamaey and kiatng authored Mar 11, 2021
1 parent cfc98cf commit 419518e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/code/core/Mage/Adminhtml/Block/Widget/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ protected function _beforeToHtml()
{
$this->_prepareForm();
$this->_initFormValues();
Mage::dispatchEvent(
'adminhtml_block_widget_form_init_form_values_after',
[
'block' => $this,
'form' => $this->getForm()
]
);
return parent::_beforeToHtml();
}

Expand Down

0 comments on commit 419518e

Please sign in to comment.