Posts Tagged ‘magento development’
23
Apr

Ok, so you have a nice custom module with a form – now you want to add basic javascript validation to it. Simple. Example,

<input type="text" name="first_name" value="" size="20" class="required-entry input-text" />

The class required-entry will make the field mandatory – this works for text-box and drop down.

If your form appears on the “one page checkout” page then, this is all you need to do.

If your form appears on its own then you will need to add this code at the bottom of your page:

<script type="text/javascript">
var customForm = new VarienForm('my-form-id');
</script>

Ensure that your form name and id are the same and that is what you need to pass to VarienForm

,

14
Apr

A quick debugging tip for developers. You can write custom messages into Magento’s system log  or exception log – helpful for knowing the current variable or object state etc.

How to enable log

Admin > System > Configuration > Developer > Log Settings
Set “Enabled” to “Yes”

Code to write into the log

Mage::log("Hello");
Mage::log("Hello Again");

Where to check?

Your custom message should most probably be in the var/log/system.log file but, in case you do not find it there, you can also check the var/log/exception.log file.

New log messages are found at the bottom of the log file.
Ensure that your log folder and files have enough permissions to write.

The log message will look like this:

2010-04-14T13:40:24+00:00 DEBUG (7): Hello
2010-04-14T13:41:31+00:00 DEBUG (7): Hello Again

, ,