Skip to content

Instantly share code, notes, and snippets.

@Mad182
Created October 14, 2014 09:05
Show Gist options
  • Save Mad182/afc81f622d4d80940d74 to your computer and use it in GitHub Desktop.
Save Mad182/afc81f622d4d80940d74 to your computer and use it in GitHub Desktop.
Create options array for cakephp form (mysql enum field)
public function getSelectOptions($column) {
$type = $this->getColumnType($column);
$menus = array();
preg_match_all("/'(.*?)'/", $type, $enums);
if (!empty($enums[1])) {
foreach ($enums[1] as $menu) {
$menus[$menu] = str_replace('_', ' ', ucfirst(__($menu)));
}
}
return $menus;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment