Note that there are some explanatory texts on larger screens.

plurals
  1. POLaravel validation attributes "nice names"
    primarykey
    data
    text
    <p>I'm trying to use the validation attributes in "language > {language} > validation.php", to replace the :attribute name (input name) for a proper to read name (example: first_name > First name) . It seems very simple to use, but the validator doesn't show the "nice names".</p> <p>I have this:</p> <pre class="lang-php prettyprint-override"><code>'attributes' =&gt; array( 'first_name' =&gt; 'voornaam' , 'first name' =&gt; 'voornaam' , 'firstname' =&gt; 'voornaam' ); </code></pre> <p>For showing the errors:</p> <pre class="lang-php prettyprint-override"><code>@if($errors-&gt;has()) &lt;ul&gt; @foreach ($errors-&gt;all() as $error) &lt;li class="help-inline errorColor"&gt;{{ $error }}&lt;/li&gt; @endforeach &lt;/ul&gt; @endif </code></pre> <p>And the validation in the controller:</p> <pre class="lang-php prettyprint-override"><code>$validation = Validator::make($input, $rules, $messages); </code></pre> <p>The $messages array:</p> <pre class="lang-php prettyprint-override"><code>$messages = array( 'required' =&gt; ':attribute is verplicht.' , 'email' =&gt; ':attribute is geen geldig e-mail adres.' , 'min' =&gt; ':attribute moet minimaal :min karakters bevatten.' , 'numeric' =&gt; ':attribute mag alleen cijfers bevatten.' , 'url' =&gt; ':attribute moet een valide url zijn.' , 'unique' =&gt; ':attribute moet uniek zijn.' , 'max' =&gt; ':attribute mag maximaal :max zijn.' , 'mimes' =&gt; ':attribute moet een :mimes bestand zijn.' , 'numeric' =&gt; ':attribute is geen geldig getal.' , 'size' =&gt; ':attribute is te groot of bevat te veel karakters.' ); </code></pre> <p>Can someone tell me what i'm doing wrong. I want the :attribute name to be replaced by the "nice name" in the attributes array (language).</p> <p>Thanks!</p> <p><strong>EDIT:</strong></p> <p>I noticed that the problem is I never set a default language for my Laravel projects. When I set the language to 'NL' the code above works. But, when I set my language, the language will appear in the url. And I prefer it doesn't. </p> <p>So my next question: Is it possible to remove the language from the url, or set the default language so it just doesn't appear there?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload