Re: showEmpty?

2009-10-04 Thread Miles J

You should only be using input().

echo $form-input('State', array('options' = array('NJ' = New
Jersey', 'NY' = 'New
York'), 'empty' = false));

On Oct 3, 7:33 pm, Gonzalo Servat gser...@gmail.com wrote:
 On Sun, Oct 4, 2009 at 7:21 AM, 
 gimperdan...@gmail.comgimperdan...@gmail.com wrote:

 [..snip..]

  This is what I have:

  echo $form-select('State', array('NJ' = New Jersey', 'NY' = 'New
  York'));

  I want to remove the empty option of this select box. According to the
  API I need to add $showEmpty = false to the code above.. but where do
  I add it? I tried in several different locations and it won't work.

 The function's arguments are:

 select($fieldName, $options = array(), $selected = null, $attributes =
 array(), $showEmpty = '')

 You only supplied the first and second arguments so if you want to
 keep the defaults for the rest except for $showEmpty, you'd need to do
 something like the following:

 echo $form-select('State', array('NJ' = 'New Jersey', 'NY' = 'New
 York'), null, array(), false)

 (notice I kept the defaults null and array() for the arguments
 between $options and $showEmpty)

 - Gonzalo
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: showEmpty?

2009-10-04 Thread Dave Maharaj :: WidePixels.com

I had a same / similar question for input selects which is related to this.

I have my echo $form-input('State'); which is populated by a find list...so
I have all my States. How can I add so first option to be Select your
State with no value? Right now Alabama shows up first and if a user does
not select a State Alabama is automatically saved.

$selected = array('option' = 'Select your State', 'value' = '0')?

Thanks,

Dave
-Original Message-
From: Miles J [mailto:mileswjohn...@gmail.com] 
Sent: October-04-09 7:35 AM
To: CakePHP
Subject: Re: showEmpty?


You should only be using input().

echo $form-input('State', array('options' = array('NJ' = New Jersey',
'NY' = 'New York'), 'empty' = false));

On Oct 3, 7:33 pm, Gonzalo Servat gser...@gmail.com wrote:
 On Sun, Oct 4, 2009 at 7:21 AM,
gimperdan...@gmail.comgimperdan...@gmail.com wrote:

 [..snip..]

  This is what I have:

  echo $form-select('State', array('NJ' = New Jersey', 'NY' = 'New 
  York'));

  I want to remove the empty option of this select box. According to 
  the API I need to add $showEmpty = false to the code above.. but 
  where do I add it? I tried in several different locations and it won't
work.

 The function's arguments are:

 select($fieldName, $options = array(), $selected = null, $attributes = 
 array(), $showEmpty = '')

 You only supplied the first and second arguments so if you want to 
 keep the defaults for the rest except for $showEmpty, you'd need to do 
 something like the following:

 echo $form-select('State', array('NJ' = 'New Jersey', 'NY' = 'New 
 York'), null, array(), false)

 (notice I kept the defaults null and array() for the arguments 
 between $options and $showEmpty)

 - Gonzalo


--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: showEmpty?

2009-10-04 Thread John Andersen

Use array_unshift( $states, $selected) to insert an element at the
beginning of the $states array.
Enjoy,
   John

On Oct 4, 3:13 pm, Dave Maharaj :: WidePixels.com
d...@widepixels.com wrote:
 I had a same / similar question for input selects which is related to this.

 I have my echo $form-input('State'); which is populated by a find list...so
 I have all my States. How can I add so first option to be Select your
 State with no value? Right now Alabama shows up first and if a user does
 not select a State Alabama is automatically saved.

 $selected = array('option' = 'Select your State', 'value' = '0')?

 Thanks,

 Dave

 -Original Message-
 From: Miles J [mailto:mileswjohn...@gmail.com]
 Sent: October-04-09 7:35 AM
 To: CakePHP
 Subject: Re: showEmpty?

 You should only be using input().

 echo $form-input('State', array('options' = array('NJ' = New Jersey',
 'NY' = 'New York'), 'empty' = false));

 On Oct 3, 7:33 pm, Gonzalo Servat gser...@gmail.com wrote:
  On Sun, Oct 4, 2009 at 7:21 AM,
 gimperdan...@gmail.comgimperdan...@gmail.com wrote:

  [..snip..]

   This is what I have:

   echo $form-select('State', array('NJ' = New Jersey', 'NY' = 'New
   York'));

   I want to remove the empty option of this select box. According to
   the API I need to add $showEmpty = false to the code above.. but
   where do I add it? I tried in several different locations and it won't
 work.

  The function's arguments are:

  select($fieldName, $options = array(), $selected = null, $attributes =
  array(), $showEmpty = '')

  You only supplied the first and second arguments so if you want to
  keep the defaults for the rest except for $showEmpty, you'd need to do
  something like the following:

  echo $form-select('State', array('NJ' = 'New Jersey', 'NY' = 'New
  York'), null, array(), false)

  (notice I kept the defaults null and array() for the arguments
  between $options and $showEmpty)

  - Gonzalo
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: showEmpty?

2009-10-04 Thread brian

I believe it's 'empty = 'Select your State'. If the param is false,
null, or the empty string, Cake outputs an empty option.

On Sun, Oct 4, 2009 at 8:13 AM, Dave Maharaj :: WidePixels.com
d...@widepixels.com wrote:

 I had a same / similar question for input selects which is related to this.

 I have my echo $form-input('State'); which is populated by a find list...so
 I have all my States. How can I add so first option to be Select your
 State with no value? Right now Alabama shows up first and if a user does
 not select a State Alabama is automatically saved.

 $selected = array('option' = 'Select your State', 'value' = '0')?

 Thanks,

 Dave
 -Original Message-
 From: Miles J [mailto:mileswjohn...@gmail.com]
 Sent: October-04-09 7:35 AM
 To: CakePHP
 Subject: Re: showEmpty?


 You should only be using input().

 echo $form-input('State', array('options' = array('NJ' = New Jersey',
 'NY' = 'New York'), 'empty' = false));

 On Oct 3, 7:33 pm, Gonzalo Servat gser...@gmail.com wrote:
 On Sun, Oct 4, 2009 at 7:21 AM,
 gimperdan...@gmail.comgimperdan...@gmail.com wrote:

 [..snip..]

  This is what I have:

  echo $form-select('State', array('NJ' = New Jersey', 'NY' = 'New
  York'));

  I want to remove the empty option of this select box. According to
  the API I need to add $showEmpty = false to the code above.. but
  where do I add it? I tried in several different locations and it won't
 work.

 The function's arguments are:

 select($fieldName, $options = array(), $selected = null, $attributes =
 array(), $showEmpty = '')

 You only supplied the first and second arguments so if you want to
 keep the defaults for the rest except for $showEmpty, you'd need to do
 something like the following:

 echo $form-select('State', array('NJ' = 'New Jersey', 'NY' = 'New
 York'), null, array(), false)

 (notice I kept the defaults null and array() for the arguments
 between $options and $showEmpty)

 - Gonzalo


 


--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: showEmpty?

2009-10-04 Thread Dave Maharaj :: WidePixels.com

Thanks,

Will give it a try.

Dave 

-Original Message-
From: brian [mailto:bally.z...@gmail.com] 
Sent: October-04-09 1:29 PM
To: cake-php@googlegroups.com
Subject: Re: showEmpty?


I believe it's 'empty = 'Select your State'. If the param is false, null,
or the empty string, Cake outputs an empty option.

On Sun, Oct 4, 2009 at 8:13 AM, Dave Maharaj :: WidePixels.com
d...@widepixels.com wrote:

 I had a same / similar question for input selects which is related to
this.

 I have my echo $form-input('State'); which is populated by a find 
 list...so I have all my States. How can I add so first option to be 
 Select your State with no value? Right now Alabama shows up first 
 and if a user does not select a State Alabama is automatically saved.

 $selected = array('option' = 'Select your State', 'value' = '0')?

 Thanks,

 Dave
 -Original Message-
 From: Miles J [mailto:mileswjohn...@gmail.com]
 Sent: October-04-09 7:35 AM
 To: CakePHP
 Subject: Re: showEmpty?


 You should only be using input().

 echo $form-input('State', array('options' = array('NJ' = New 
 Jersey', 'NY' = 'New York'), 'empty' = false));

 On Oct 3, 7:33 pm, Gonzalo Servat gser...@gmail.com wrote:
 On Sun, Oct 4, 2009 at 7:21 AM,
 gimperdan...@gmail.comgimperdan...@gmail.com wrote:

 [..snip..]

  This is what I have:

  echo $form-select('State', array('NJ' = New Jersey', 'NY' = 'New 
  York'));

  I want to remove the empty option of this select box. According to 
  the API I need to add $showEmpty = false to the code above.. but 
  where do I add it? I tried in several different locations and it 
  won't
 work.

 The function's arguments are:

 select($fieldName, $options = array(), $selected = null, $attributes 
 = array(), $showEmpty = '')

 You only supplied the first and second arguments so if you want to 
 keep the defaults for the rest except for $showEmpty, you'd need to 
 do something like the following:

 echo $form-select('State', array('NJ' = 'New Jersey', 'NY' = 'New 
 York'), null, array(), false)

 (notice I kept the defaults null and array() for the arguments 
 between $options and $showEmpty)

 - Gonzalo


 




--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



showEmpty?

2009-10-03 Thread gimperdan...@gmail.com

I am new to cake... i have been doing a lot of reading, but somethings
i still can't figure out.

This is what I have:

echo $form-select('State', array('NJ' = New Jersey', 'NY' = 'New
York'));

I want to remove the empty option of this select box. According to the
API I need to add $showEmpty = false to the code above.. but where do
I add it? I tried in several different locations and it won't work.

Thanks

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: showEmpty?

2009-10-03 Thread Gonzalo Servat

On Sun, Oct 4, 2009 at 7:21 AM, gimperdan...@gmail.com
gimperdan...@gmail.com wrote:
[..snip..]
 This is what I have:

 echo $form-select('State', array('NJ' = New Jersey', 'NY' = 'New
 York'));

 I want to remove the empty option of this select box. According to the
 API I need to add $showEmpty = false to the code above.. but where do
 I add it? I tried in several different locations and it won't work.

The function's arguments are:

select($fieldName, $options = array(), $selected = null, $attributes =
array(), $showEmpty = '')

You only supplied the first and second arguments so if you want to
keep the defaults for the rest except for $showEmpty, you'd need to do
something like the following:

echo $form-select('State', array('NJ' = 'New Jersey', 'NY' = 'New
York'), null, array(), false)

(notice I kept the defaults null and array() for the arguments
between $options and $showEmpty)

- Gonzalo

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



$form-input as dateTime wrapper doesn't map correctly the dateTime showEmpty option

2008-07-05 Thread operativo

Hi

I used the FormHelper $form-input() method to wrap a dateTime this
way:

echo $form-input('expire',array(
  'type'='datetime',
  'dateFormat' = 'DMY',
  'timeFormat' = '24',
  'selected' = null,
  'attributes' = array(),
  )
);

I read in the dateTime options that the default behaviour is to show
an empty default value (as showEmpty = true is the default), so I
didn't pass anything because I want an empty value. By the way if I
call it this way I get a default value in it.

So I tried to call the input() this way:

echo $form-input('expire',array(
  'type'='datetime',
  'dateFormat' = 'DMY',
  'timeFormat' = '24',
  'selected' = null,
  'attributes' = array(),
  'showEmpty' = true
  )
);

but the result was the same. Looking inside the input() method I found
that to get an empty default value you should set the empty option,
which is set to false per default. Finally calling it with...

echo $form-input('expire',array(
  'type'='datetime',
  'dateFormat' = 'DMY',
  'timeFormat' = '24',
  'selected' = null,
  'attributes' = array(),
  'empty' = true
  )
);

... gives me the desired result. I think that the mapping between the
options in the input() method and the options in the dateTime() method
should be consistent to avoid people to look inside the code to
discover the correct mapping.

Regards

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: passing showEmpty from $form-input to a select

2008-04-11 Thread Dardo Sordi Bogado

http://book.cakephp.org/view/201/options-empty

On Fri, Apr 11, 2008 at 11:52 AM, RichardAtHome [EMAIL PROTECTED] wrote:

  Hi All :-)

  Cake 1.2.0.6311 beta

  I am using the following code to create a drop down select box for a
  field in a view:

  echo $form-input('institution_id',array(label=Institution *,
  class=input, div=input mandatory, selected=$preSelect-
  select(institution_id)));

  ($preSelect is a custom helper that pre-selects an item from the list
  if it is present in the URL)

  As it stands, this code creates a drop down list as expected, but
  doesn't include an empty option.

  How do I get it to show an empty option at the top of the list (or
  better yet a 'Please Select...' option)?

  I've dug through the form helper code and I though this would work:

  echo $form-input('institution_id',array(label=Institution *,
  class=input, div=input mandatory, selected=$preSelect-
  select(institution_id)),null,null,Please Select);

  and

  echo $form-input('institution_id',array(label=Institution *,
  class=input, div=input mandatory, selected=$preSelect-
  select(institution_id), showEmpty=Please Select...));

  but try as I might, I can't get $form-input() to pass the Please
  Select message through to $form-select()

  Oddly enough, the $input-select() code should default to providing an
  empty select code ($showEmpty = '') if non is specified, so $form-
  input() must be passing in false to stop this from happening.

  Any ideas what I'm doing wrong?

  Thanks in advance :-)
  


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---