Created
October 14, 2014 09:05
-
-
Save Mad182/afc81f622d4d80940d74 to your computer and use it in GitHub Desktop.
Create options array for cakephp form (mysql enum field)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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