Support the ongoing development of Laravel.io →
posted 1 year ago
Laravel
Last updated by @tvbeek 1 year ago.
0
moderator

Hello @mia-gh

In the update function of your controller you have 'user_id'=>'required', while the user_id isn't part of the edit form. If you want to update the user_id you need to add it to the form. Else you need to remove it from the validation part.

ps. I have updated your post to have the codeblocks working :)

0

Thanks you for your kind reply. I deleted the user_id from the controller so I don't get this message, if I would like to keep it , what is the specific code for the edit file ? and thank you for the codeblocks, how did you make it ? (i am a real beginner...) have a nice day!

0
<div class="col-xs-12 col-sm-12 col-md-12 pb-5">
    <label class="font-bold text-lg">Select User:</label>
    <div class="form-group">
        <select class="form-control w-full text-black" name="user_id">
            <option value="" selected disabled>Select a user</option>
@if($users)
            @foreach ($users as $user)
                <option value="{{ $user->id }}">{{ $user->name}}</option>
            @endforeach
@endif
        </select>
    </div>
</div>

in controller 
public function edit (Info $info)
     {
$users = User::get();
      
      return view('infos.edit',compact('info',users));
 
   }
Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Sienna mia-gh Joined 14 Jun 2023

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.