Monday, December 17, 2012

Re: select box link and jump to selected category

thanks cricket,... I'll go dig into it,... I'll update you with results,... 
thank you so much for your help,... you are responding to almost any post that I make,... 


On Saturday, December 15, 2012 12:37:38 PM UTC-8, cricket wrote:
D'oh! Screwed up twice. That's not the Sluggable I meant. Use this one:


That other one is a really lame "update" of the original.


On Sat, Dec 15, 2012 at 3:18 PM, lowpass <zijn.d...@gmail.com> wrote:
On Fri, Dec 14, 2012 at 7:55 PM, Chris <chri...@yahoo.com> wrote:
hi cricket,... 
this is what I got so far: 
it's kind of works,... but then again not completely,.... I'm loosing categories value: 

No, you're not losing the values; you want something other than the defaults, but haven't taken the right steps to achieve that.
 
<?php echo $this->Form->create('', array('id'=>'FormId')); ?>
<?php echo $this->Form->input("categories" , array('label' => false, 'type' => 'select', 'value'=>$categories, 'options'=>$categories)) ?>

echo $this->Form->select('categories', $categories, array('options' => false));
 
this is output: 
where it should be 
value=arts 
value=autos 
etc... 

You need to tell Cake that you want something other than the default id & name when you do a find('list').


Presumably, you have a slug column. Don't use the Category.name as the option values because they may contain URL-unfriendly characters. Use SluggableBehavior. There seem to be several floating around the internet. Here's a recent one:


 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: