How can I keep selected the previous value when updating a form?

Rabbi Mahmud

I am using laravel collctive form. I want to update only the quantity field of the following form keeping the blood_id field readonly. When I submit the form I am not getting blood_id value.

How can i solve it?

{!! Form::model($bloodBank, ['route' => ['bloodBanks.update', $bloodBank->id], 'method' => 'put']) !!}
    <div class="row">

        <div class="col-lg-8">
            <div class="form-group">
                {!! Form::label('blood_id', 'Blood Group', ['class' => 'form-control-label']);!!}
                {!! Form::select('blood_id', $bloods ,  null , ['placeholder' => 'Choose Blood Group',"class"=>"form-control",'disabled' => true]) !!}
             </div>
        </div>

    </div>
    <div class="row">

        <div class="col-lg-8">
            <div class="form-group">

              {!! Form::label('quantity','Quantity', ['class' => 'form-control-label']);!!}
              {!! Form::number("quantity",null, ["class"=>"form-control form-control-label",'min'=>'0']) !!}
              <span class="validation-error">{{ $errors->first("quantity") }}</span>
              
            </div>
        </div><!-- col-12 -->

    </div>
    
    <button class="btn btn-info">Update </button>
{!! Form::close() !!}
George Brotherston

For disabled fields, you may want to add hidden fields which won't display on the rendered page BUT will be included in the request object. E.g.
{{ Form::hidden('blood_id', $bloods) }}
This is in addition to the displayed field you already have which is disabled.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do i keep the selected value in the dropdown menu when the form is submitted?

How to submit form with selected value when i use onchange

How can I update a variable to keep track of the current value minus the previous value in Python?

How do I keep a secondary GET variable, when updating the form in HTML

When prepending data to vertically-scrolled document, how can I keep previous part visible?

How can I enable next dropdown selection if current is selected and disable again when previous gets unselected?

How can I keep a search index updated with proper data in Laravel, when updating content directly with database?

How to keep a dropdown value selected after form.submit?

How can i change Form value Action based on dropdown value selected

How can I go back to the previous page after updating?

How can I get value when submit form on the vue component?

How can I get previous value java?

how can I set value with a previous condition?

How can I disable browser go to previous page when making HTML form.submit()?

How can i change the previous fraction value when the fraction value is 5. in c language

How can I ignore previous selection and write only last selected

How can I keep updating my ListBox synchronously

How to keep the previous value if not NULL

when i fill a form input it shows the previous value in console log

How to keep the selected value from the dropdown when the page is changed?

How can i access in reactive form async data in template to set selected value for mat-select

On a web form, how can I move a value from an 'unselected' to a 'selected' group using javascript console?

How can I get the selected value from a SelectList in a view to the controller without using a form post?

Flutter - How can I save the selected index of DropDownMenu to FireStore when the form is submitted

How can I remove selected text and keep empty HTML tags?

How can I get the selected value in the real-time, when I'm scrolling the UIPickerView

How can I reset pct change to NaN when another column value is different than previous row?

How can I undo changes and retrieve previous form state in winform?

How can I change the value of a Django model field when a particular choice is selected?