You may also do something like 'empty' => 'Select Company' and pass a string if you want to customise that particular option.
On 27 August 2014 14:15, Jipson Thomas <[email protected]> wrote: > Hi Stephen, > Thank you very much. It is working for me now. The amendment I made on > view file is as follows > > echo $this->Form->input('company_id',['options' => $company_list,'empty' > =>true]); > > Regards, > Jipson > > > On Wednesday, 27 August 2014 14:03:56 UTC+1, Stephen S wrote: > >> As per the CakePHP 3 API you can still pass empty to $this->Form->select >> (similar to 2.x) >> http://api.cakephp.org/3.0/class-Cake.View.Helper.FormHelper.html#_select >> >> This isn't mentioned in the CakePHP 3 FormHelper book though it seems. >> >> >> On 27 August 2014 13:54, Jipson Thomas <[email protected]> wrote: >> >>> Hi, >>> Would you please let me know how I can add a Null option to Cake php3 >>> form helper. >>> >>> In my drop down I am listing all the company names from database, but I >>> don't know how I can add a null option to this. Because of this, I am >>> compelled to select any company and it is not letting me to choose no >>> company. >>> >>> The Code I use is as following. >>> >>> Controller >>> ====== >>> $this->set('company_list',$company_list); >>> >>> View >>> ========= >>> echo $this->Form->select('company_id',['Company' => $company_list]); >>> >>> Thanks, >>> Jipson >>> >>> -- >>> 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 unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected]. >>> >>> Visit this group at http://groups.google.com/group/cake-php. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> Kind Regards >> Stephen Speakman >> > -- > 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 unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/cake-php. > For more options, visit https://groups.google.com/d/optout. > -- Kind Regards Stephen Speakman -- 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 unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
