Thursday, February 12, 2009

Indenting Tree List in Form Input Select using ' ' as spacer

This is the scenario in cakePHP 1.2.

In your controller, you have an action:


function add() {
...
$categories = $this->Listing->Category->generatetreelist(null, null, null, ' ');
$this->set(compact('categories','keywords','metros','states'));
}


where ' ' is your spacer.

Your view will have something like this:


...
echo $form->input('Category');
...


The above combination will display a drop down menu with the '&nsbp;' printed as '&nbsp' and not as a space. So how would you do it in cakePHP 1.2?

The key here is in the view file.

instead of the above statement, you should have this:


...
echo $form->input('Category', array('escape' => false));
...


Hope this one helps.

2 comments:

Hire PHP Programmer said...

Good Article Bro.. It really works well. Helped me.

Dave said...

holy crap, i've been looking for the solution this for a while, so simple! thanks!