mercredi 31 août 2016

Laravel5: Form-model binding - Radio buttons auto select causing problems when creating new record

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:







from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2bWWTpl
via IFTTT

Aucun commentaire:

Enregistrer un commentaire