Laravel-Administrator enum使用数字key

参考连接:Enum filter with numeric values

修改FieldsEnum::build()方法

$options['options'][] = array(
				'id' => is_numeric($val) && (!array_key_exists('enum_numeric_keys', $options) || $options['enum_numeric_keys'] == false) ? $text : $val,
				'text' => $text,
			);

使用时,添加一个'enum_numeric_keys'=>true,

/**
   * The editable fields
   */
  'edit_fields' => array(

    'type' => array(
    	'enum_numeric_keys'=>true,
      	'title' => 'test',
      	'type'  => 'enum',

	  	'options' => array(
  			'1' => 'text1',
  			'2' => 'text2',
  			'3' => 'text3',
  			'4' => 'text4'
  		),
    )
  ),
原文地址:https://www.cnblogs.com/fsong/p/6182376.html