1
votes

I am trying to create my own / custom form blade templates in Laravel 5 but I am seeing that only the input Form::text is taking class "form-control" from array (['class' => 'form-control']) despite the other inputs have proper values:

{!! Form::open(['url' => 'ingreso']) !!}

    <div class="form-group">
        {!! Form::label('email', 'E-mail:', ['class' => 'control-label']) !!}
        {!! Form::email('email', null, ['class' => 'form-control']) !!}
    </div>

    <div class="form-group">
        {!! Form::label('password', 'Contrase&ntilde;a:', ['class' => 'control-label']) !!}
        {!! Form::password('password', '', ['class' => 'form-control']) !!}
    </div>

    <div class="form-group">
        {!! Form::label('remember', 'Recordarme:', ['class' => 'control-label']) !!}
        {!! Form::checkbox('remember', Input::has(''), ['class' => 'form-control']) !!}
    </div>

    <div class="form-group">
        {!! Form::submit('Ingresar', ['class' => 'btn btn-primary']) !!}
    </div>
{!! Form::close() !!}

This shows me the following:

And this in source code:

<form method="POST" action="***" accept-charset="UTF-8"><input name="_token" type="hidden" value="4BRX8b03ycb7AU4J0iCCXhSWFfxaMC6ugZ19oy75">

    <div class="form-group">
        <label for="email" class="control-label">E-mail:</label>
        <input class="form-control" name="email" type="email" id="email">
    </div>

    <div class="form-group">
        <label for="password" class="control-label">Contrase&ntilde;a:</label>
        <input name="password" type="password" value="" id="password">
    </div>

    <div class="form-group">
        <label for="remember" class="control-label">Recordarme:</label>
        <input checked="checked" name="remember" type="checkbox" value="" id="remember">
    </div>

    <div class="form-group">
        <input class="btn btn-primary" type="submit" value="Ingresar">
    </div>
</form>

Any clues?

1

1 Answers

3
votes

The password field does not have a default value passed as a second parameter, because in case of a form error the password is not a field you want to repopulate. Which means the second parameter is actually the array of attributes being passed to the input element:

{!! Form::password('password', ['class' => 'form-control']) !!}

You can see the actual method definition from the FormBuilder class here.