We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://github.com/summerblue/administrator/blob/master/docs/field-type-enum.md 里面写了 You can either provide a simple array of strings, or if the key is a string, the key will be saved to the database while the value will be presented to the user. 您可以提供一个简单的字符串数组,或者如果键是字符串,则键将保存到数据库中,而值将呈现给用户。
如果array的key是string型的 数据库是整型integer的 是无法成功保存的 例如: 'state'=>[ 'title'=>'审核', 'type'=>'enum', 'options'=>array('1'=>'未审核','2'=>'过审核','3'=>'不过审核'), ],
但如果没有键的数组 即使值是string型的 也能保存进整型integer的数据库
例如: 'state'=>[ 'title'=>'审核', 'type'=>'enum', 'options'=>array('1','2','3'), ],
The text was updated successfully, but these errors were encountered:
额我发现这行话都是错的 或者如果键是字符串,则键将保存到数据库中,而值将呈现给用户。 即使键是字符串 也不会把键保存到数据库 而是把值保存到数据库了
Sorry, something went wrong.
多检查了几次 好像是因为数组的key是数字导致的 如果是别的字符就正常了 array('1'=>'未审核','2'=>'过审核','3'=>'不过审核'),
最后发现是Enum.php里面build()函数判断的问题 从 'id' => is_numeric($val) ? $text : $val, 改成 'id' => is_string($val) ? $text : $val, 这样就可以解决
'id' => is_numeric($val) ? $text : $val,
'id' => is_string($val) ? $text : $val,
No branches or pull requests
https://github.com/summerblue/administrator/blob/master/docs/field-type-enum.md
里面写了
You can either provide a simple array of strings, or if the key is a string, the key will be saved to the database while the value will be presented to the user.
您可以提供一个简单的字符串数组,或者如果键是字符串,则键将保存到数据库中,而值将呈现给用户。
如果array的key是string型的 数据库是整型integer的 是无法成功保存的
例如:
'state'=>[
'title'=>'审核',
'type'=>'enum',
'options'=>array('1'=>'未审核','2'=>'过审核','3'=>'不过审核'),
],
但如果没有键的数组 即使值是string型的 也能保存进整型integer的数据库
例如:
'state'=>[
'title'=>'审核',
'type'=>'enum',
'options'=>array('1','2','3'),
],
The text was updated successfully, but these errors were encountered: