mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -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') {
|
if ($field->element == 'checkbox') {
|
||||||
//Log::alert($field->formatFieldValuesAsArray());
|
//Log::alert($field->formatFieldValuesAsArray());
|
||||||
$values = $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){
|
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)) {
|
if(!is_array($value)) {
|
||||||
$exploded = explode(',', $value);
|
$exploded = explode(',', $value);
|
||||||
$valid = array_intersect($exploded, $options);
|
$invalid = array_diff($exploded, $options);
|
||||||
if(array_count_values($valid) > 0) {
|
if(count($invalid) > 0) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
if(is_array($value)) {
|
|
||||||
$valid = array_intersect($value, $options);
|
$valid = array_intersect($value, $options);
|
||||||
if(array_count_values($valid) > 0) {
|
if(array_count_values($valid) > 0) {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue