mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Possible fix for asset model editing when no custom fieldset is associated
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
476e17055b
commit
bbb0d1be17
|
@ -19,13 +19,22 @@ class CustomFieldSetDefaultValuesForModel extends Component
|
|||
{
|
||||
$this->model = AssetModel::find($this->model_id); // It's possible to do some clever route-model binding here, but let's keep it simple, shall we?
|
||||
$this->fieldset_id = $this->model->fieldset_id;
|
||||
$this->fields = CustomFieldset::find($this->fieldset_id)->fields;
|
||||
$this->add_default_values = ( $this->model->defaultValues->count() > 0);
|
||||
|
||||
$this->fields = null;
|
||||
|
||||
if ($fieldset = CustomFieldset::find($this->fieldset_id)) {
|
||||
$this->fields = CustomFieldset::find($this->fieldset_id)->fields;
|
||||
}
|
||||
|
||||
$this->add_default_values = ($this->model->defaultValues->count() > 0);
|
||||
}
|
||||
|
||||
public function updatedFieldsetId()
|
||||
{
|
||||
$this->fields = CustomFieldset::find($this->fieldset_id)->fields;
|
||||
if (CustomFieldset::find($this->fieldset_id)) {
|
||||
$this->fields = CustomFieldset::find($this->fieldset_id)->fields;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
|
|
@ -12,9 +12,10 @@
|
|||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@if( $this->add_default_values ) {{-- 'if the checkbox is enabled *AND* there are more than 0 fields in the fieldsset' --}}
|
||||
@if ($this->add_default_values ) {{-- 'if the checkbox is enabled *AND* there are more than 0 fields in the fieldsset' --}}
|
||||
<div>
|
||||
<div class="form-group">
|
||||
@if ($fields)
|
||||
@foreach ($fields as $field)
|
||||
<div class="form-group">
|
||||
|
||||
|
@ -49,6 +50,7 @@
|
|||
</div>
|
||||
|
||||
@endforeach
|
||||
@endif
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue