Skip to content

Commit

Permalink
Turn cusotm fields required/optional/remove into POST requests
Browse files Browse the repository at this point in the history
Signed-off-by: snipe <snipe@snipe.net>
  • Loading branch information
snipe committed Nov 5, 2021
1 parent fba0e2b commit 0d811d0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
25 changes: 16 additions & 9 deletions resources/views/custom_fields/fieldsets/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 3 additions & 3 deletions routes/web/fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']
);
Expand Down

0 comments on commit 0d811d0

Please sign in to comment.