Merge pull request #10279 from snipe/fixes/turn_get_into_post_for_custom_field_required

Turn custom fields required/optional/remove into POST requests
This commit is contained in:
snipe 2021-11-08 14:37:36 -08:00 committed by GitHub
commit edf98cb795
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 12 deletions

View file

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

View file

@ -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']
);