mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 14:27:33 -08:00
Added support for radio buttons in Custom Fields. (#9053)
This commit is contained in:
parent
fb482b0dd6
commit
6772835efc
|
@ -287,7 +287,7 @@ class CustomField extends Model
|
||||||
{
|
{
|
||||||
$arr = preg_split("/\\r\\n|\\r|\\n/", $this->field_values);
|
$arr = preg_split("/\\r\\n|\\r|\\n/", $this->field_values);
|
||||||
|
|
||||||
if (($this->element!='checkbox') && ($this->element!='checkbox')) {
|
if (($this->element!='checkbox') && ($this->element!='radio')) {
|
||||||
$result[''] = 'Select '.strtolower($this->format);
|
$result[''] = 'Select '.strtolower($this->format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Format -->
|
<!-- Format -->
|
||||||
<div class="form-group {{ $errors->has('format') ? ' has-error' : '' }}">
|
<div class="form-group {{ $errors->has('format') ? ' has-error' : '' }}" id="format_values">
|
||||||
<label for="format" class="col-md-4 control-label">
|
<label for="format" class="col-md-4 control-label">
|
||||||
{{ trans('admin/custom_fields/general.field_format') }}
|
{{ trans('admin/custom_fields/general.field_format') }}
|
||||||
</label>
|
</label>
|
||||||
|
@ -168,6 +168,17 @@
|
||||||
});
|
});
|
||||||
}).change();
|
}).change();
|
||||||
|
|
||||||
|
// If the element is a radiobutton, doesn't show the format input box
|
||||||
|
$(".field_element").change(function(){
|
||||||
|
$(this).find("option:selected").each(function(){
|
||||||
|
if (($(this).attr("value") != "radio")){
|
||||||
|
$("#format_values").show();
|
||||||
|
} else{
|
||||||
|
$("#format_values").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).change();
|
||||||
|
|
||||||
// Only display the field element if the type is not text
|
// Only display the field element if the type is not text
|
||||||
$(".field_element").change(function(){
|
$(".field_element").change(function(){
|
||||||
$(this).find("option:selected").each(function(){
|
$(this).find("option:selected").each(function(){
|
||||||
|
|
|
@ -27,6 +27,17 @@
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
@elseif ($field->element=='radio')
|
||||||
|
@foreach ($field->formatFieldValuesAsArray() as $value)
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label>
|
||||||
|
<input type="radio" value="{{ $value }}" name="{{ $field->db_column_name() }}" class="minimal" {{ isset($item) ? ($item->{$field->db_column_name()} == $value ? ' checked="checked"' : '') : (Request::old($field->db_column_name()) != '' ? ' checked="checked"' : '') }}>
|
||||||
|
{{ $value }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue