/** * Fetches the enum values from a table and returns an array suitable for * use with Form::select. * * @param string table name * @param string enum field name * @param array array of values to exclude from the returned array * * @return array in the form array('option1'=>'option1', 'option1'=>'option1' etc... ) */ public static function get_enum_values($table, $field, $exclusions = array()) { $column = DB::list_columns($table, $field); $options = array_values($column[$field]['options']); $options = array_diff($options, $exclusions); return array_combine($options, $options); }
Paul Boco wrote on Sunday 29th of May 2011:Not sure if this will help you, but I use this.
/** * Fetches the enum values from a table and returns an array suitable for * use with Form::select. * * @param string table name * @param string enum field name * @param array array of values to exclude from the returned array * * @return array in the form array('option1'=>'option1', 'option1'=>'option1' etc... ) */ public static function get_enum_values($table, $field, $exclusions = array()) { $column = DB::list_columns($table, $field); $options = array_values($column[$field]['options']); $options = array_diff($options, $exclusions); return array_combine($options, $options); }
It looks like you're new here. If you want to get involved, click one of these buttons!