Skip to content

Commit

Permalink
working! need formatting for error messages etc
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerrlongg committed Sep 25, 2024
1 parent f3ad899 commit 9df78a9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
8 changes: 8 additions & 0 deletions app/Livewire/CustomFieldSetDefaultValuesForModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ public function mount($model_id = null)
$this->fieldset_id = $this->model?->fieldset_id;
$this->add_default_values = ($this->model?->defaultValues->count() > 0);


$this->initializeSelectedValuesArray();
if (session()->has('errors')) {
$errors = session('errors')->keys();
$selectedValuesKeys = array_keys($this->selectedValues);
if (count(array_intersect($selectedValuesKeys, $errors)) > 0) {
$this->add_default_values = true;
};
}
$this->populatedSelectedValuesArray();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@
<div class="col-md-3">
@if ($fieldset_id)
<label class="form-control">

{{ Form::checkbox('add_default_values', 1, old('add_default_values', $add_default_values), ['data-livewire-component' => $this->getId(), 'id' => 'add_default_values', 'wire:model.live' => 'add_default_values', 'disabled' => $this->fields->isEmpty()]) }}
{{ trans('admin/models/general.add_default_values') }}
</label>
@endif
</div>
</div>

@if ($add_default_values || $errors->count() > 0)
@if ($this->fields)
@if ($add_default_values)

@if ($this->fields)

@foreach ($this->fields as $field)
@if($errors->has($field->db_column_name()))
Expand Down
2 changes: 1 addition & 1 deletion resources/views/models/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<!-- Custom Fieldset -->
<!-- If $item->id is null we are cloning the model and we need the $model_id variable -->
@livewire('custom-field-set-default-values-for-model', ["model_id" => $item->id ?? $model_id ?? null, "errors" => $errors])
@livewire('custom-field-set-default-values-for-model', ["model_id" => $item->id ?? $model_id ?? null])

@include ('partials.forms.edit.notes')
@include ('partials.forms.edit.requestable', ['requestable_text' => trans('admin/models/general.requestable')])
Expand Down

0 comments on commit 9df78a9

Please sign in to comment.