Laravel-admin: [NEED HELP] Form edit alway go to mode create first ?

Created on 12 Feb 2017  ·  4Comments  ·  Source: z-song/laravel-admin

How to check mode create or mode edit in form ?
I have a case
if form mode create then validate A
if form mode edit then validate B
But current form alway go validate A
The label have been change to email 2
I have been debugged ID alway is NULL before it is a numeric after submitting form @z-song
:(

https://gyazo.com/8292b5c1b397a9240b06947dfee28bca

https://gyazo.com/8288ba30225a7dbb24abf14b47add506

https://gyazo.com/41fd1d6e4e17734ea0154c45bf8ead54

https://gyazo.com/0c964bfe613515896856641e01494567

https://gyazo.com/c598893c473a2f9b7ffdc34cb2aa4e33

Most helpful comment

Just add following code to your controller:

public function update($id)
{
    return $this->form($id)->update($id);
}

All 4 comments

The method update of trait ModelForm will handle update request, so you always get NULL because in update method there is no parameters passed to form method.

The only thing you need to do is just override the update method in your controller, and pass id to form method.

Thanks for your support
Can you give some line of code to help me ?

Just add following code to your controller:

public function update($id)
{
    return $this->form($id)->update($id);
}

IT works thank you

Was this page helpful?
0 / 5 - 0 ratings