domingo, 2 de diciembre de 2007

Javascript debug information with firebug

Debugging javascript code can be really a pain in the ass. But if you use firebug Firefox extension you can easily output any important code directly to the console.

Just type in your code:

console.log('hello world!!!!');


Firebug has much more great features and I cannot imagine writing javascript or ajax code without using it. Definitely this is the best firefox extension ever.

How to setup default form values in cakephp

If you want to configure some default values for the form you can use the model's create function this way:



//in you booking model
function create($data) {
if (empty($data['Booking']['country_id'])) {
$data['Booking']['country_id'] = 225;
}

parent::create($data);
}


this would preconfigure country_id value to 255

Update:
In order to have these data available in your view you must setup $this->data variable in your controller:


$this->data = $this->Booking->create();


you can also setup $this->data variable directly in your controller:

$this->data['Booking']['country_id'];


* if you are testing it with firefox be aware that the browser doesn't refresh your form data values until you press ctrl+f5

new cake on the table

so here we are! When I found the cakephp framework a couple of months ago I was really impressed by the ease of use and multiple features it had. Very well organized, clearly defined - this is what a busy programmer needs!

After all these months that have passed (and a couple of successfully implemented projects) I still discover new features that put a little smile on my face. And as I like the whole idea of sharing I created this site to put down what I find and learn.

I hope you will find it useful.