Friday, February 24, 2012

Form input selected

Hi,

I am using the ajax pagination and my url looks like this:
/search/cat:12/city:67/sleeps:1/price:2

I have for each a dropdown input select:
$this->Form->input('cat', array('options' => $getCategories,
'selected' => $this->request->params['named']['cat']));

But what I want to know, what is best practice, because on first call
of the form and their input selects I get the error:
Undefined index: cat

Which is clear for me, but do I have really to check before is the
value is present? Like
$selectedCat = ($this->request->params['named']['cat'])?$this->request-
>params['named']['cat']:'';
echo $this->Form->input('cat', array('options' => $getCategories,
'selected' => $selectedCat));

Is this best practice?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: