PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, January 18, 2022

[FIXED] How do I set the default drop-down list?

 January 18, 2022     cakephp     No comments   

Issue

I encountered such a problem, CakePHP created a drop-down list, but I can not figure out how to set it to the default value, if the user did not choose that the system set the default value by itself. And how can you give it a placeholder, such as that there is no one inside to say "Choose"?

Tell me, please, in advance grateful.

At the moment the list has this kind of appearance

enter image description here

Code Listing of the drop-down list

$this->Form->select('progress', array([0 => 'One', 1=> 'Two', 2=>'Three']));

Solution

Try this:

$this->Form->select('progress', [0 => 'One', 1=> 'Two', 2=>'Three'], ['empty' => '(Choose One)']);


Answered By - Derek
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing