Determine Active Record type for before validation

Hello, I added a before validate class to perform certain actions when ARs are new or updated (such as auditing logs,etc.).

I’m trying to control the type of record it is to perform the necessary actions needed for the various records. Any ideas how to do this?

Thanks for your help. Something like:

<?php

if(&#036;this-&gt;isNewRecord AND &#036;this-&gt; type =='User'){


	// set the create date, last updated date and the user doing the creating


}


	else if (&#036;this-&gt;isNewRecord AND &#036;this-&gt; type =='Customer')	{


// set the create date, last updated date and the user doing the creating


}

?>

if you just want to audit / log , there is some extension you can read like :audittrail :rolleyes:

Please use code blocks to make your code readable (use the "<>" symbol in the editor toolbar, or write [code ] … [/code ].

What you want to do is just using scenarios. When you declare rules, you can specify if they must be applied on "insert", "update", "search", or everywhere (default). See the official guide, Declaring validation rules.