I'm using I'm using laravel 5.5 and laravel collective to build my forms.
During validation, to manage errors and putting back the old values, I'm using this kind of code:
<div class="@if ($errors->has( $question->title )) has-error @endif">
{!! Form::label($question->title, $question->title) !!}
{!! Form::text($question->title, null, ['class' => 'form-control']) !!}
@if ($errors->has($question->title)) <p class="help-block"></p> @endif
</div>
And everything is working well. But I'm facing a problem where my name attributes contains white spaces.
When the page is displayed my name attributes are well writen with white space by example Are you happy?
But the validation return error mentioning Are_you_happy? so the old values are not putted back and the errors messages are not displayed due to the _.
I was thinking of using regex to "sanitize" the values in my forms but the error message will still be The Are_you_happy? field is required. So not that good.
Is there any tricks or better ways to proceed? Or is it just a bad practice to have whitespace?
More info
This also happen with the dot character ., it's is replaced by an _ during validation.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire