Reputation: 24059
I have a form:
{{ Form::open(array('route' => 'process', 'method'=>'POST','data-abide' => '')) }}
<fieldset>
<div class="name-field">
{{ Form::label('name', 'Name') }}
{{ Form::text('name', null, array('required' => '', 'pattern' => 'alpha')) }}
<small class="error">A valid name is required.</small>
</div>
<div class="password-field">
{{ Form::label('password', 'Password') }}
{{ Form::password('password', null, array('id' => 'password', 'required' => '')) }}
<small class="error">Bad password.</small>
</div>
<div class="password-confirm-field">
{{ Form::label('password-confirm', 'Confirm Password') }}
{{ Form::password('confirm-password', null, array('required' => '', 'data-equalto' => 'password')) }}
<small class="error">The password did not match.</small>
</div>
</fieldset>
{{ Form::close() }}
My name field error works, when the input does not match the pattern, the error appears.
I'm having trouble with the password field:
Checking that the confirm password field is the same as the password field does not work. This is because this is never passed to the page:
'data-equalto' => 'password'
I presume this is a problem with laravel as when I manually add it in using dev tools, the validation works. How can I fix it so that this param is passed to the page?
I leave my password field blank and the error is not shown, I though having the field automatically set as password meant it had to abide to certain rules, so an error should be shown - why is it not shown?
Upvotes: 0
Views: 251
Reputation: 4753
You are using the wrong syntax for password method. According to the code the method signature is:
/**
* Create a password input field.
*
* @param string $name
* @param array $options
* @return string
*/
public function password($name, $options = array())
...
It has only two parameters but you are passing three, so the 3rd paramers is being ignored.
You should use instead
{{ Form::password('password', array('id' => 'password', 'required' => '')) }}
Note the only change is the second parameter is gone.
Upvotes: 2