Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

gman01's avatar

edit date in form

Hi, Me again!

I'm building an edit form and the date of Birth shows the default (d-m-y), doesn't fetch from the database. Whats the best way to add this in?

            <div class="col-xs-4">
                        <div class="form-group">
                        {!! Form::label('date_of_birth', 'Date of Birth:') !!}
                        {!! Form::date('date_of_birth', date('D-m-y'), ['class' => 'form-control']) !!}

                </div>                 
            </div>
0 likes
7 replies
tykus's avatar

date('D-m-y') will give you the current date in the format Fri-09-16; as @jbowman99 says you need to use the Model object's date_of_birth property as the second argument to the Form::date() method. This assumes that you have the model available to the view?

gman01's avatar

I can get it out like this & it updates fine. But i'm using the same form to also create a record also and then it breaks.

     <div class="col-xs-4">
                        <div class="form-group">
                        {!! Form::label('date_of_birth', 'Date of Birth:') !!}
                        {!! Form::date('date_of_birth', date($client->date_of_birth), ['class' => 'form-control']) !!}

                </div>                 
            </div>





tykus's avatar

Pass an empty Client object to the create view

1 like

Please or to participate in this conversation.