From 419518eeb1a5a4fd3bc804e86b42ccae93ae2f67 Mon Sep 17 00:00:00 2001 From: Wouter Samaey Date: Thu, 11 Mar 2021 02:59:59 +0100 Subject: [PATCH] New event "init_form_values_after" after data set on a form (#1485) * 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 Co-authored-by: Ng Kiat Siong --- app/code/core/Mage/Adminhtml/Block/Widget/Form.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Form.php b/app/code/core/Mage/Adminhtml/Block/Widget/Form.php index 35e94e2bd72..a205acbc73c 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Form.php @@ -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(); }