Reputation: 2123
I have replaced my entity with Blog
to explain better.
I have the following route:
Route::get('/blog-category', 'BlogController@showBlogCategory')
which shows a form with a dropdown of different blog categories and some other input fields related to the category
The form POST
s to the following:
Route::post('/blog-details', 'BlogController@showBlogDetails')
Here I validate the request the form and return back if there is an invalid blog category or if it is missing
This method is called showBlogDetails
because the category and the other fields are passed on to the next view return view('blog-details', compact('blogCategoryData'))
In this view there is a form to fill in the rest of the blog details.
Both the blogCategoryData
(each data has a hidden input field) and the blog details are POST
ed to the following route:
Route::post('/blog-store', 'BlogController@store')
This is also validated using a Request
but if it fails it tries to go back, which it can't do as only POST
is allowed to get there.
I need the blog category fields before I can show the blog details and a Blog
cannot be created without either stuff so I can't temporarily create one either.
This flow of selecting/filling in blog category fields and then entering details is a requirement so has to be done in that order, in 2 different pages.
So currently it is:
GET -> POST (validate) -> POST (validate)
What is the best way around this or how would I make my current flow work?
Upvotes: 0
Views: 266
Reputation: 723
one way is to use javascript and of course ajax to fetch blog data and show corresponding section. first the page only shows categories drop down box. after changing that to a correct category page makes an ajax request and fetches data. then replaces it in a hidden 'div' and shows it.
another way is to bring replace the categories box in the previous page.
Upvotes: 1