1 year ago

Setting the existing value on a drop down box when using partial for edit and create form fields

Posted 1 year ago by RossUK

I am trying to reduce code duplication by having a partial for my create and edit customer form fields.

    <form action="/customer/{{$customer->id}}" method="POST" enctype="multipart/form-data">

                     {{ csrf_field() }}

             {!! method_field('patch') !!}



I have a select menu for title eg. Mr. , Mrs. Miss etc Im not sure how to set the selected attribute in my edit and delete form for both old('title) and also $customer->title

I have done the below on the create form

<option value="Mr." {{ old('title') === "Mr." ? "selected" : "" }}>Mr.</option>

But not sure how to do this for edit and create?

Please sign in or create an account to participate in this conversation.