I have custom module which adds admin form. There is a button "Save" in the form container that saves the entire form and adds some data to the database.
I would like to avoid situation that user accidentally clicks the button. How to add a javascript to the button that would display (on button click) a pop-up window with text like:
"Are you sure you want save? Yes/No"?
If user clicks "Yes", then the default action for the "Save" button will be triggered and form will be submitted. If user clicks "No" then nothing happens. This will prevent accidentally saving the form.
Is there anything like this available in magento admin forms? If not, how to add this feature to my form?
class Super_Awesome_Block_Adminhtml_Example_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
public function __construct()
{
parent::__construct();
$this->_blockGroup = 'awesome';
$this->_controller = 'adminhtml_example';
$this->_addButton(
'my_button_save',
array(
'label' => Mage::helper('adminhtml')->__('Save'),
'class' => 'save',
),
100
);
}
}