Skip to content
Permalink
Browse files
Turn cusotm fields required/optional/remove into POST requests
Signed-off-by: snipe <snipe@snipe.net>
  • Loading branch information
snipe committed Nov 5, 2021
1 parent fba0e2b commit 0d811d067c8e064252c0143c39d6cd4c3133679e
Showing with 19 additions and 12 deletions.
  1. +16 −9 resources/views/custom_fields/fieldsets/view.blade.php
  2. +3 −3 routes/web/fields.php
@@ -57,21 +57,28 @@
<td>{{$field->element}}</td>
<td>{{ $field->field_encrypted=='1' ? trans('general.yes') : trans('general.no') }}</td>
<td>

@if ($field->pivot->required)
<a href="{{ route('fields.optional', [$custom_fieldset->id, $field->id]) }}">
<i class="fa fa-check text-success" aria-hidden="true"></i>
<span class="sr-only">Required - click to make optional</span>
</a>
<form method="post" action="{{ route('fields.optional', [$custom_fieldset->id, $field->id]) }}">
@csrf
<button type="submit" class="btn btn-link"><i class="fa fa-check text-success" aria-hidden="true"></i></button>
</form>

@else
<a href="{{ route('fields.required', [$custom_fieldset->id, $field->id]) }}">
<i class="fa fa-times text-danger" aria-hidden="true"></i>
<span class="sr-only">Optional - click to make required</span>
</a>

<form method="post" action="{{ route('fields.required', [$custom_fieldset->id, $field->id]) }}">
@csrf
<button type="submit" class="btn btn-link"><i class="fa fa-times text-danger" aria-hidden="true"></i></button>
</form>
@endif

</td>
<td>
@can('update', $custom_fieldset)
<a href="{{ route('fields.disassociate', [$field, $custom_fieldset->id]) }}" class="btn btn-sm btn-danger">Remove</a>
<form method="post" action="{{ route('fields.disassociate', [$field, $custom_fieldset->id]) }}">
@csrf
<button type="submit" class="btn btn-sm btn-danger">Remove</button>
</form>
@endcan
</td>
</tr>
@@ -7,17 +7,17 @@

Route::group([ 'prefix' => 'fields','middleware' => ['auth'] ], function () {

Route::get('required/{fieldset_id}/{field_id}',
Route::post('required/{fieldset_id}/{field_id}',
['uses' => 'CustomFieldsetsController@makeFieldRequired',
'as' => 'fields.required']
);

Route::get('optional/{fieldset_id}/{field_id}',
Route::post('optional/{fieldset_id}/{field_id}',
['uses' => 'CustomFieldsetsController@makeFieldOptional',
'as' => 'fields.optional']
);

Route::get('{field_id}/fieldset/{fieldset_id}/disassociate',
Route::post('{field_id}/fieldset/{fieldset_id}/disassociate',
['uses' => 'CustomFieldsController@deleteFieldFromFieldset',
'as' => 'fields.disassociate']
);

0 comments on commit 0d811d0

Please sign in to comment.