selectDefaultValue

Navigation:  Development > Function Reference > Helpers > Html >

selectDefaultValue

Previous pageReturn to chapter overviewNext page

This function used to set default value form an array.
 
App::Html()->selectDefaultValue(Data Array, Key, [Default Value]);

 

Parameter

Description

Data Array

List of element to create options group

Key

Field name to check in array

Default Value

Return if value does not exists

 

See bellow example:
 

$row = array(
  "id" => 5,
  "name" => "Jhon Regan",
  "email" => "jhon@example.com"
);   
   
// Return jhon@example.com
echo App::Html()
    ->selectDefaultValue(
        $row,
        "email",
        "email not defined"
    );
   
// Return N/A
echo App::Html()
    ->selectDefaultValue(
        $row,
        "address",
        "N/A"
    );