Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If the status can be registered or cancelled then you can use enum data type in your table schema.</p> <p>You can get the list of status from enum data type for populating drop down like this.</p> <pre><code>$status = $this-&gt;Model-&gt;getEnumValues('status'); </code></pre> <p>Before this you need to add following code in your appModel.php</p> <pre><code>function getEnumValues($columnName=null) { if ($columnName==null) { return array(); } //no field specified //Get the name of the table $db =&amp; ConnectionManager::getDataSource($this-&gt;useDbConfig); $tableName = $db-&gt;fullTableName($this, false); //Get the values for the specified column (database and version specific, needs testing) $result = $this-&gt;query("SHOW COLUMNS FROM {$tableName} LIKE '{$columnName}'"); //figure out where in the result our Types are (this varies between mysql versions) $types = null; if ( isset( $result[0]['COLUMNS']['Type'] ) ) { $types = $result[0]['COLUMNS']['Type']; } //MySQL 5 elseif ( isset( $result[0][0]['Type'] ) ) { $types = $result[0][0]['Type']; } //MySQL 4 else { return array(); } //types return not accounted for //Get the values $values = explode("','", preg_replace("/(enum)\('(.+?)'\)/","\\2", $types) ); //explode doesn't do assoc arrays, but cake needs an assoc to assign values $assoc_values = array(); foreach ( $values as $value ) { //leave the call to humanize if you want it to look pretty $assoc_values[$value] = Inflector::humanize($value); } return $assoc_values; } </code></pre> <p>I hope this will work for you. Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload