3

I'm using Laravel PHP Framework with Bootstrap. I want to know how to insert a datepicker in to a form.

I already have the bootstrap-datepicker installed but do not know how I will use.

Here is the code of my form:

{{ Form::open(array('action' => 'HomeController@postRegister')) }}
        <p>{{ Form::text('first_name', '', array('class' => 'form-control','placeholder' => 'primeiro nome')) }}</p>
        <p>{{ Form::text('last_name', '', array('class' => 'form-control','placeholder' => 'último nome')) }}</p>
        <p>{{ Form::text('email', '', array('class' => 'form-control','placeholder' => 'email')) }}</p>
        <p>{{ Form::text('phone_number', '', array('class' => 'form-control','placeholder' => 'o teu número de telemóvel')) }}</p>
        **<p>{{ Form::text('date_of_birth', '', array('class' => 'form-control','placeholder' => 'a tua data de nascimento')) }}</p>**
        <p>{{ Form::password('password', array('class' => 'form-control','placeholder' => 'a tua palavra-passe')) }}</p>
        <p>{{ Form::password('password', array('class' => 'form-control','placeholder' => 'reintroduzir palavra-passe')) }}</p>
        <p>{{ Form::submit('regista-te', array('class' => 'btn btn-danger')) }}</p>
        {{ Form::close() }}

I need to replace this code for a datepicker:

<p>{{ Form::text('date_of_birth', '', array('class' => 'form-control','placeholder' => 'a tua data de nascimento')) }}</p>

Like this:

As a componet: enter image description here

I hope someone can help me :)

Thanks!

2 Answers 2

2

Twitter bootstrap uses

 data-datepicker="datepicker"

to show the date picker. Laravel will allow you to use this is the same array as the class and placeholder.

<p>{{ Form::text('date_of_birth', '', array('class' => 'form-control','placeholder' => 'a tua data de nascimento','data-datepicker' => 'datepicker')) }}</p>
Sign up to request clarification or add additional context in comments.

Comments

2

The following has worked for me. Difference between @Marco's and my answer is data-provide instead of data-datepicker.

{{ Form::text('startingDate', null, array('class' => 'form-control input-sm','placeholder' => 'Starting Date','data-provide' => 'datepicker')) }}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.