mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 13:57:41 -08:00
Added feature: Checkbox Custom Fields as list of values. (#9112)
* Added functionality for checkboxes in custom fields. Similar to how radio buttons work. * Added the same functionality when the custom fieldset is encrypted. * Added missing bits, so the edit custom assets view shows what values have been already stored in database
This commit is contained in:
parent
f89d789832
commit
12ff465cdb
|
@ -165,10 +165,17 @@ class AssetsController extends Controller
|
|||
foreach ($model->fieldset->fields as $field) {
|
||||
if ($field->field_encrypted=='1') {
|
||||
if (Gate::allows('admin')) {
|
||||
$asset->{$field->convertUnicodeDbSlug()} = \Crypt::encrypt($request->input($field->convertUnicodeDbSlug()));
|
||||
}
|
||||
if(is_array($request->input($field->convertUnicodeDbSlug()))){
|
||||
$asset->{$field->convertUnicodeDbSlug()} = \Crypt::encrypt(e(implode(', ', $request->input($field->convertUnicodeDbSlug()))));
|
||||
}else{
|
||||
$asset->{$field->convertUnicodeDbSlug()} = \Crypt::encrypt(e($request->input($field->convertUnicodeDbSlug())));
|
||||
} }
|
||||
} else {
|
||||
$asset->{$field->convertUnicodeDbSlug()} = $request->input($field->convertUnicodeDbSlug());
|
||||
if(is_array($request->input($field->convertUnicodeDbSlug()))){
|
||||
$asset->{$field->convertUnicodeDbSlug()} = implode(', ', $request->input($field->convertUnicodeDbSlug()));
|
||||
}else{
|
||||
$asset->{$field->convertUnicodeDbSlug()} = $request->input($field->convertUnicodeDbSlug());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -342,10 +349,18 @@ class AssetsController extends Controller
|
|||
foreach ($model->fieldset->fields as $field) {
|
||||
if ($field->field_encrypted=='1') {
|
||||
if (Gate::allows('admin')) {
|
||||
$asset->{$field->convertUnicodeDbSlug()} = \Crypt::encrypt(e($request->input($field->convertUnicodeDbSlug())));
|
||||
if(is_array($request->input($field->convertUnicodeDbSlug()))){
|
||||
$asset->{$field->convertUnicodeDbSlug()} = \Crypt::encrypt(e(implode(', ', $request->input($field->convertUnicodeDbSlug()))));
|
||||
}else{
|
||||
$asset->{$field->convertUnicodeDbSlug()} = \Crypt::encrypt(e($request->input($field->convertUnicodeDbSlug())));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$asset->{$field->convertUnicodeDbSlug()} = $request->input($field->convertUnicodeDbSlug());
|
||||
if(is_array($request->input($field->convertUnicodeDbSlug()))){
|
||||
$asset->{$field->convertUnicodeDbSlug()} = implode(', ', $request->input($field->convertUnicodeDbSlug()));
|
||||
}else{
|
||||
$asset->{$field->convertUnicodeDbSlug()} = $request->input($field->convertUnicodeDbSlug());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,10 +168,10 @@
|
|||
});
|
||||
}).change();
|
||||
|
||||
// If the element is a radiobutton, doesn't show the format input box
|
||||
// If the element is a radiobutton/checkbox, doesn't show the format input box
|
||||
$(".field_element").change(function(){
|
||||
$(this).find("option:selected").each(function(){
|
||||
if (($(this).attr("value") != "radio")){
|
||||
if (($(this).attr("value") != "radio") && ($(this).attr("value") != "checkbox")){
|
||||
$("#format_values").show();
|
||||
} else{
|
||||
$("#format_values").hide();
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" value="1" name="{{ $field->db_column_name() }}[]" class="minimal" {{ Request::old($field->db_column_name()) != '' ? ' checked="checked"' : '' }}>
|
||||
<input type="checkbox" value="{{ $value }}" name="{{ $field->db_column_name() }}[]" class="minimal" {{ isset($item) ? (in_array($key, explode(', ', $item->{$field->db_column_name()})) ? ' checked="checked"' : '') : (Request::old($field->db_column_name()) != '' ? ' checked="checked"' : '') }}>
|
||||
{{ $value }}
|
||||
</label>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue