selectTag

Navigation:  Development > Function Reference > Helpers > Html >

selectTag

Previous pageReturn to chapter overviewNext page

Create a select Tag.
 
App::Html()->selectTag(Name, Data Array, Selected, Html Options, Parameter);

 

Parameter

Description

Name

Name of the Input element

Data Array

List of element to create options group

Selected

Default selected value

Options

HTML Attributes

Parameter

Pass extra parameter. For example off_blank to remove empty option.

 

See bellow example:

 

echo App::Html()
    ->selectTag(
        "data[Player][choice]",
        array("I"=>"In Door Game","O"=>"Out Door Game"),
        "I",
        array(
            "id"=>"choice"
        )
);
/*

Return 
<select name="data[Player][choice]"  id="choice"  >
  <option value=""></option>
  <option selected="selected" value="I">In Door Game</option>
  <option value="O">Out Door Game</option>
</select>
*/  

 
echo App::Html()
    ->selectTag(
        "data[Player][choice]",
        array("I"=>"In Door Game","O"=>"Out Door Game"),
        "I",
        array(
            "id"=>"choice"
        ),
    array(
      "off_blank" => "Yes"
    )
);   
 
/* 
Return value 
<select name="data[Player][choice]"  id="choice"  >

  <option selected="selected" value="I">In Door Game</option>

  <option value="O">Out Door Game</option>

</select>
*/