Merge pull request #11830 from inietov/fixes/default_values_for_checkboxes_unaccessible

Fixed #9801 #11199 Default Values for Checkbox Field Types Unaccessible
This commit is contained in:
snipe 2022-09-15 11:28:15 -07:00 committed by GitHub
commit 51d7f2b97b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -235,6 +235,10 @@ class CustomFieldsController extends Controller
$field->format = e($request->get('format')); $field->format = e($request->get('format'));
} }
if($field->element == 'checkbox' || $field->element == 'radio'){
$field->format = 'ANY';
}
if ($field->save()) { if ($field->save()) {
return redirect()->route('fields.index')->with('success', trans('admin/custom_fields/message.field.update.success')); return redirect()->route('fields.index')->with('success', trans('admin/custom_fields/message.field.update.success'));
} }

View file

@ -46,7 +46,9 @@
<input type='radio' name="default_values[{{ $field->id }}]" value="{{$field_value}}" {{ $field->defaultValue($model_id) == $field_value ? 'checked="checked"': '' }} />{{ $field_value }}<br /> <input type='radio' name="default_values[{{ $field->id }}]" value="{{$field_value}}" {{ $field->defaultValue($model_id) == $field_value ? 'checked="checked"': '' }} />{{ $field_value }}<br />
@endforeach @endforeach
@elseif($field->element == "checkbox") @elseif($field->element == "checkbox")
<input type='checkbox' name="default_values[{{ $field->id }}]" {{ $field->defaultValue($model_id) ? 'checked="checked"': '' }}/> @foreach(explode("\r\n", $field->field_values) as $field_value)
<input type='checkbox' name="default_values[{{ $field->id }}][]" value="{{$field_value}}" {{ in_array($field_value, explode(', ',$field->defaultValue($model_id))) ? 'checked="checked"': '' }} /> {{ $field_value }}<br />
@endforeach
@else @else
<span class="help-block form-error"> <span class="help-block form-error">
Unknown field element: {{ $field->element }} Unknown field element: {{ $field->element }}