Merge pull request #12132 from snipe/fixes/view_assets_page_error_when_no_custom_fields
Handle use case where there are no custom fields for any assigned models
This commit is contained in:
commit
cdcd19a7d8
1 changed files with 13 additions and 4 deletions
|
@ -38,14 +38,23 @@ class ViewAssetsController extends Controller
|
||||||
'licenses',
|
'licenses',
|
||||||
)->find(Auth::user()->id);
|
)->find(Auth::user()->id);
|
||||||
|
|
||||||
|
$field_array = array();
|
||||||
|
|
||||||
// Loop through all the custom fields that are applied to any model the user has assigned
|
// Loop through all the custom fields that are applied to any model the user has assigned
|
||||||
foreach ($user->assets as $asset) {
|
foreach ($user->assets as $asset) {
|
||||||
foreach ($asset->model->fieldset->fields as $field) {
|
|
||||||
// check and make sure they're allowed to see the value of the custom field
|
// Make sure the model has a custom fieldset before trying to loop through the associated fields
|
||||||
if ($field->display_in_user_view == '1') {
|
if ($asset->model->fieldset) {
|
||||||
$field_array[$field->db_column] = $field->name;
|
|
||||||
|
foreach ($asset->model->fieldset->fields as $field) {
|
||||||
|
// check and make sure they're allowed to see the value of the custom field
|
||||||
|
if ($field->display_in_user_view == '1') {
|
||||||
|
$field_array[$field->db_column] = $field->name;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since some models may re-use the same fieldsets/fields, let's make the array unique so we don't repeat columns
|
// Since some models may re-use the same fieldsets/fields, let's make the array unique so we don't repeat columns
|
||||||
|
|
Loading…
Add table
Reference in a new issue