I'm using Form-Model binding and the same view partial for both creating and editing a user.
While trying auto-select radio buttons based on db values upon Edit
, The correct item selects by default, which is the expected result. But when I try creating a new user using the same form partial, it gives an error Undefined variable: user
because we didn't pass a $user
variable on the create method, which seems unnecessary. How do I fix this?
Controller Methods:
public function create()
{
return view('backend/users/create');
}
public function edit(User $user)
return view('backend/users/edit', compact('user'));
}
Form radio buttons:
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire