Users can submit news and edit them afterwards. My question, should they have the same view file with a few ifs if(page == edit) echo "edit news" else echo "submit news" and similar?
Users can submit news and edit them afterwards. My question, should they have the
Share
I think sharing the same form for add/edit is the way to go, and much more DRY (Don’t repeat yourself). In Ruby on Rails, it’s a a really good practice/standard to do that.
So yeah, create two views for add and edit, but include the same form in both of your views, so you would have something like:
and you would simply include the _form.php in each of the file.
I would still create two views because most of the time you have different texts, images and other things surrounding the form, so if you don’t want to have ifs everywhere, I would create two views to keep things organized and clean 🙂