Skip to content
Advertisement

mb_strtoupper on a Laravel form with Blade Template

I tried to use the PHP mb_strtoupper function on a form, but the parameter of the function does not appear in my form. For example:

<input type="text" name="nome" value="{{mb_strtoupper(trans('nome'))}}" class="form-control @error('nome') is-invalid @enderror" />

How do I pass the name parameter of the form correctly to the mb_strtoupper function?

Advertisement

Answer

Laravel has a build-in fonction to uppercase strings, it does use mb_strtoupper().

<input type="text" name="nome" value="{{ illuminateSupportstr::upper(__('nome')) }}" class="form-control @error('nome') is-invalid @enderror" />

I think your problem is not the uppercase function but the lang() function. You should call the file name then a point then the name of the string key.

<input type="text" name="nome" value="{{ illuminateSupportstr::upper(trans('message.nome')) }}" class="form-control @error('nome') is-invalid @enderror" />

trans() Laravel documentation

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement