I have create a model which have own database table
.For a customization i need to trigger save_before event of this mode
l.
Trigger if my one field value is not match then data is not save in table
My main target is prevent the data save using before save event
My config.xml code is look
<?xml version="1.0" ?>
<config>
<modules>
<Amit_Custommodule>
<version>1.0.0</version>
</Amit_Custommodule>
</modules>
<global>
<models>
<custommodule>
<class>Amit_Custommodule_Model</class>
<resourceModel>custommodule_resource</resourceModel>
</custommodule>
<custommodule_resource>
<class>Amit_Custommodule_Model_Resource</class>
<entities>
<custommodule>
<table>custommodule</table>
</custommodule>
</entities>
</custommodule_resource>
</models>
<resources>
<custommodule_setup>
<setup>
<module>Amit_Custommodule</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</custommodule_setup>
<custommoule_read>
<connection>
<use>core_read</use>
</connection>
</custommoule_read>
<custommodule_write>
<connection>
<use>core_write</use>
</connection>
</custommodule_write>
</resources>
<events>
<custommodule_save_before>
<observers>
<custommodule>
<type>singleton</type>
<class>custommodule/observer</class>
<method>customerSaveAfter</method>
</custommodule>
</observers>
</custommodule_save_before>
</global>
</config>
Observer.php
<?php
class Amit_Custommodule_Model_Observer
{
public function customerSaveAfter($observer){
if($observer->getEvent()->getMyfield()==MatchWithMyLogic){
}
else
{
/* i want prevent data base if my business logic is not match here */
}
}
}