mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 14:27:33 -08:00
maybe i do the inverse here?
This commit is contained in:
parent
dcf2168454
commit
57a75e68b9
|
@ -102,7 +102,7 @@ class CustomFieldset extends Model
|
|||
if ($field->element == 'checkbox') {
|
||||
//Log::alert($field->formatFieldValuesAsArray());
|
||||
$values = $field->formatFieldValuesAsArray();
|
||||
//$rules[$field->db_column_name()] = 'checkboxes';
|
||||
$rules[$field->db_column_name()] = 'checkboxes';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -298,15 +298,15 @@ class ValidationServiceProvider extends ServiceProvider
|
|||
});
|
||||
|
||||
Validator::extend('checkboxes', function ($attribute, $value, $parameters, $validator){
|
||||
$options = CustomField::where('db_column', $attribute)->formatFieldValuesAsArray();
|
||||
$options = CustomField::where('db_column', $attribute)->first()->formatFieldValuesAsArray();
|
||||
// for legacy, allows users to submit a comma separated string of options
|
||||
if(!is_array($value)) {
|
||||
$exploded = explode(',', $value);
|
||||
$valid = array_intersect($exploded, $options);
|
||||
if(array_count_values($valid) > 0) {
|
||||
return true;
|
||||
$invalid = array_diff($exploded, $options);
|
||||
if(count($invalid) > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(is_array($value)) {
|
||||
} else {
|
||||
$valid = array_intersect($value, $options);
|
||||
if(array_count_values($valid) > 0) {
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue