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

Aronaman's avatar

input field not show "old value"

Hello guys how are you :)

i am store data using database transaction of two tables at ones. The problem is while i edit old value of the first table not showing

Admin.org.edit Blade


{!! Form::model($orgsAdmin, ['method' => 'PATCH','route' => ['orgsAdmin.update', $orgsAdmin->id], 'enctype'=>'multipart/form-data']) !!}


<div class="form-row">
    <div class="form-group col-md-6  {{ $errors->has('manager_name') ? 'has-error' : '' }}">
        <label for="manager_name">Manager Name:</label>
        <input type="text" class="form-control"  id="manager_name" placeholder="Manager Name" name="manager_name" value="{{ old('manager_name', isset($basicOrgInfo) ? $basicOrgInfo->manager_name : '') }}" required>
         @if($errors->has('manager_name'))
                    <em class="invalid-feedback">
                        {{ $errors->first('manager_name') }}
                    </em>
                @endif
                <p class="helper-block">
                    {{ trans('cruds.basicOrgInfo.fields.manager_name_helper') }}
                </p>
    </div>

    <div class="form-group col-md-6">

        <div class="form-group">

            <strong>Tel:</strong>

            {!! Form::text('tel', null, array('placeholder' => ' Telephone No','class' => 'form-control')) !!}

        </div>

    </div>

     <div class="form-group col-md-6">

        <div class="form-group">

            <strong>TIN NO:</strong>

            {!! Form::text('tin_no', null, array('placeholder' => 'Tax Identification Number','class' => 'form-control')) !!}

        </div>

    </div>

     <div class="form-group col-md-6">

        <div class="form-group">

            <strong>Vat No:</strong>

            {!! Form::text('vat_no', null, array('placeholder' => 'Value Add Tax Number','class' => 'form-control')) !!}

        </div>

    </div>


// this second table it is working show me old value 

  <div class="col-xs-12 col-sm-12 col-md-12">

        <div class="form-group">

            <strong>slug:</strong>

            {!! Form::text('slug', null, array('placeholder' => ' slug','class' => 'form-control')) !!}

        </div>

    </div>

    <div class="col-xs-12 col-sm-12 col-md-12">

        <div class="form-group">

            <strong>Feature Image:</strong>
                <div class="needsclick dropzone" id="feature_image-dropzone">

                    {!! Form::file('feature_image', null, array('placeholder' => 'Feature Images','class' => 'needsclick dropzone')) !!}
                    
                </div>

        </div>

    </div>
..
...
....
    

Controller

public function update(Request $request, Organization $orgsAdmin)
    {
        DB::beginTransaction();
        try{
            
            $attrubute=$this->validate($request, [
            'manager_name'=>'required|min:3',
            'tel'=>'required',      
            'tin_no'=>'required|unique:basic_org_infos|min:10',
            'vat_no'=>'required|unique:basic_org_infos|min:10',
            
        ]);
 
 $user_id=$request->input('user_id');
           
             $attrubute['user_id']=$user_id;
.
.
.

0 likes
7 replies
Nakov's avatar

@aronaman using form collective there are parameters that you have set as null so you should fill those with old values instead, for example:

{!! Form::text('tel', null, array('placeholder' => ' Telephone No','class' => 'form-control')) !!}

should be:

{!! Form::text('tel', old('tel', $orgsAdmin->tel), array('placeholder' => ' Telephone No','class' => 'form-control')) !!}

Do the same for the other fields.

Nakov's avatar

@aronaman not the create method but the edit method, do you pass an orgsAdmin that has those values in?

Plus the old() helper will help you fill the form when you submit it but the validation returned errors.

Nakov's avatar

@aronaman okay, you need to debug my friend, I don't have your code..

when you do dd($orgsAdmin) do you see values for the fields on the page, like: tel, tin_no and so on?

Nakov's avatar

@aronaman I already gave you help, you just need to find the way to use the correct data.. Try this:

{!! Form::text('tin_no', old('tin_no', '10000000'), array('placeholder' => 'Tax Identification Number','class' => 'form-control')) !!}

Will the field contain '10000000' value?

How did deleting your replies helped you?

Aronaman's avatar

if you are try to store data in 2 table using one controller use db Transaction and in "edit" method use the database relationship to fetch the data

like this

  public function store(Request $request, ....)
    {

        DB::beginTransaction();
        try{
...
 if(... && ...){

        DB::commit();
        
    }else{

        DB::rollback();
    }
return...
}

        catch(Exception $ex)
        {
            DB::rollback();
        }

and in the edit

 public function edit(A $a)
    {
        $basic=$a->basicOrgInfo;// relationship on the A model 
}

just give you hit on my problem & i solve it 
thanks .
Nakov's avatar

@aronaman and how did you solved it? You are not using the old() helper that I suggested?

Snapey's avatar

How has two tables and transactions got anything to do with providing the original value for the form?

You need to show the controller code where you prepare data for the form and pass $basicOrgInfo

As for the other fields, as a rule, I don't help anyone using that form package

Please or to participate in this conversation.