Feature request: multimode CRUD actions

Requested:

The ability to create actions and forms that transparently handle any one of three modes: create / edit / view.

If you visit the page, and no id is passed, the form becomes a blank create form
If you pass an id, the form is an edit form
If the controller detects some condition (user permissions, for example, or a user flag of some kind) the page is presented not as a form but as a view entity page.

I do this kind of thin by hand, very often, but it can get painful and tedious. Especially if I used bake to scaffold my site, because bake creates three different actions and ctp files for each.

Hi calzone,

Did you consider using crud and crud-view plugins?

1 Like

Thank you for the referral. That’s definitely a neat looking tool and sure to be helpful for a lot of future projects.

That aside, it doesn’t sound like it totally addresses the need I was speaking to. It basically sounds like a great way to bake a project, but my feature request is not merely about getting started, it’s about taking DRY to a whole next level.

I figure for 90% of forms out there, we are going to use the exact same form, validation, css, js, etc regardless of whether it’s a create new or edit existing. Moreover, I think for a high percentage of those forms, most dev are going to want the read-only view page to follow the same layout and format, just not with form fields.

So why reuse the same queries and layout code 3 times over when you could have one layout and controller handle all three uses cases? Then we could code andy exceptions inline and the whole thing would super-DRY.