Merge pull request #4 from snipe/develop

Merge current develop into branch
This commit is contained in:
Nuraeil 2021-11-18 21:30:45 +01:00 committed by GitHub
commit 7084703b5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View file

@ -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()

View file

@ -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>