1

Hi guys so i have this update page where i need to display data of a user that are currently inside my database. Among this data is the birthday of the user so im trying display the birthday on Form::input that is a datepicker but the birthday can't be seen any idea on how will i make the datepicker display the birthday of the user from the database? for now i have this code

<div class="form-group">
        {{ Form::label('date', 'Birthday') }} Current: {{ $sinf->Birthdate }} </br>
        {{ Form::input('date', '$sinf->Birthdate', Input::old('date'), ['class'=>'datepicker',  'placeholder' => '$sinf->Birthdate']) }}<span class="errmsg" style="color:red"><i>{{ $errors->first('date', ':message') }}</i></span>
    </div>
2
  • By "can't be seen", you mean the data isn't being put in the field and it just shows the placeholder? Commented Feb 22, 2016 at 15:49
  • yup the record from the database is not reflected in the Form::input on my view Commented Feb 23, 2016 at 10:49

1 Answer 1

3

There are a few things wrong with your code as listed below:

1. Date input elements don't have placeholder attributes as per the W3C HTML5 Recommendation.

2. The order and values you pass to the Form::input method don't match the ones defined by the API. The Illuminate\Html\FormBuilder::input method accepts the following parameters in the following order: type, name, value, options.

3. The value you pass to the date input must be in ISO 8601 format (meaning YYYY-MM-DD), although the browsers will use their own presentation format which may differ from browser to browser (for example Chrome will display the date according to the client locale, so you while you pass the date in the required format of YYYY-MM-DD, it might be displayed as DD/MM/YYYY, that however is not an issue because the value that will be passed back to the server will still be in ISO 8601 format). This last point may not be an actual issue, as you haven't specified the value of $sinf->Birthdate, but it was worth mentioning.

So based on the points made above your date input code should look something like this:

{{ Form::input('date', 'birthdate', $sinf->Birthdate, ['class'=>'datepicker']) }}

So assuming the value of $sinf->Birthdate is equal to 2015-02-22 then the HTML generated by that will be:

<input class="datepicker" name="birthdate" type="date" value="2015-02-22">

And it will show the birthdate value correctly in the browser.

Sign up to request clarification or add additional context in comments.

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.