You have to set() the variable afterwards. You're adding a value to a
purely local variable.
array_unshift($counties, array(none=Pick me!));
$this-set(compact('counties'));
$this-render('/examples/ajax_dropdown');
On Sat, Aug 29, 2009 at 11:28 PM,
FrederickDmanzanillo.engl...@gmail.com wrote:
Thanks Brian! I received both your message on this thread and on the
other one.
Adding the statements below in the controller function had no effect.
function getCounties() {
$this-set('options',
$this-Example-County-find('list',
array(
'conditions' = array(
Not one to give up easily, if at all... I gave it another try. I
remember reading a post somewhere that an easy way to add an entry to
the beginning of a dropdown list was like this:
echo $form-input(
'county_id',
array(
'options' = array('Please pick a country') + $counties
)
);
Hi
I have a select box that is populated by a database:
$isps = $this-Consultation-Isp-find('list');
and then output using the form helper in the view:
echo $form-select('isp_id', $isps, array('selected' =
$ispselect),
array(), 'select your supplier');
This
Hey there... this thread may hold the answer to my post that is here:
http://groups.google.com/group/cake-php/browse_thread/thread/25fa39d4e10bff7c#
Would one of you please take a quick look at my question on the
thread? I tried the array_unshift and put it in my controller just
before the
Hi,
That's easy. You can use array_unshift to add an entry to the start of
an array. Just add this to your controller:
$isps = $this-Consultation-Isp-find('list');
array_unshift($isps, array(none=None of the above));
And you should be all set.
Greets,
Melgior.
Yes, you could use array_push() indeed, although you don't even need
to. The PHP manual recommends this method if you want to add just one
entry:
$isps['none'] = None of the above;
This way 'none' will show up as last in the dropdown, as long as you
put the line after -find().
forgot something...
If you save the value none to your database and in the other cases
0, 1, 2, 3 (id's of the suppliers...) and so on your code should
probably look like this:
$form-input(Modelname.isp_id, array(
'empty' = __('Select your supplier', true)
);
The 'empty' key of the array
Hey,
nice one, didn't know about that. Would it be correct for an added
value at the END of the array to use array_push() ?
On 27 Aug., 20:48, Melgior melg...@hotmail.com wrote:
Hi,
That's easy. You can use array_unshift to add an entry to the start of
an array. Just add this to your
Thanks all for your help, worked a charm!
Thanks again :)
c5
--~--~-~--~~~---~--~~
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
10 matches
Mail list logo