Clean up empty HTML and help text in form inputs (#700)
* Clean up empty HTML and help text in form inputs * Update api/app/Http/Requests/UserFormRequest.php Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: Julien Nahum <julien@nahum.net> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
@@ -14,6 +14,22 @@ use Illuminate\Validation\Rule;
|
||||
*/
|
||||
abstract class UserFormRequest extends \Illuminate\Foundation\Http\FormRequest
|
||||
{
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$data = $this->all();
|
||||
|
||||
if (isset($data['properties']) && is_array($data['properties'])) {
|
||||
$data['properties'] = array_map(function ($property) {
|
||||
if (isset($property['help']) && is_string($property['help']) && strip_tags($property['help']) === '') {
|
||||
$property['help'] = null;
|
||||
}
|
||||
return $property;
|
||||
}, $data['properties']);
|
||||
}
|
||||
|
||||
$this->merge($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user