CRUD-S base controller

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

CRUD-S base controller

Post by alex.barylski »

I've been reading up on RAD frameworks from various languages/communities trying to get a feel for some of the latest and greatest. One thing I keep seeing (thought nothing polished enough to really catch my fancy) is CRUD-S controllers. Making it easy for developers to a framework to radpily produce boiler plate code.

From what I have gathered, most seem to want to provide some base MVC component that generates a HTML form, client side validation, server side validation and schema updates and data updates. Some even go as far as offering a listing service.

Without going into to much detail (it's all pretty new to me and I have several concerns or doubts which I don't want to detract from the main question of this post) given what I have above. How do you (or do you even) attempt to meet this requirement half way, all the way, etc in your own frameworks???

Small real examples would be awesome. I know Zend has a form library, similar to HTML_QuickForm in PEAR (which is not new). These let you build forms programmatically/dynamically at runtime so adding/removing fields is a snap and thus you can avoid creating two HTML forms (one for update another for create).

I assume a controller is needed in the mix to facilitate the submission capture, validation, and ultimately data storage?

I guess i am just interested to hear of others attempts to RAD in this regard

Cheers,
Alex
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: CRUD-S base controller

Post by Christopher »

I googled "CRUD-S" and found nothing? Do just mean "CRUD"?

And ... I have found these kind of solutions to definitely suffer from diminishing returns. As you add features the size of the code balloons. I tend to go for middle complexity solutions that are consistent across a range of for complexities.
(#10850)
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: CRUD-S base controller

Post by alex.barylski »

I googled "CRUD-S" and found nothing? Do just mean "CRUD"?
I always say CRUD-S meaning the "S" to stand for selection or listings, but same idea, just with additional funcitonality.
And ... I have found these kind of solutions to definitely suffer from diminishing returns. As you add features the size of the code balloons. I tend to go for middle complexity solutions that are consistent across a range of for complexities.
I have yet to find/discover a solution I felt good about. Part of the problem is with form creation. You create a form programmatically, and the output is dictated by the form class itself, or maybe even templates. Having complete control over the template is important for me, as I often work with designers on side jobs and they always want 'precision' form design, example: First and Last name fields on the same row, Helper links, Icons, etc. This is especially true when you use a UI CRUD solution and later attempt to theme it and move fields around with CSS.

Can you think of any particular issues you experienced in the past? Offer any experience insight you can, so I don't repeat the same thing? :)

Cheers,
Alex
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: CRUD-S base controller

Post by Christopher »

alex.barylski wrote:I always say CRUD-S meaning the "S" to stand for selection or listings, but same idea, just with additional funcitonality.
I think Paginated Listing + CRUD record editing is sometimes called a Grid these days.
alex.barylski wrote:I have yet to find/discover a solution I felt good about. Part of the problem is with form creation. You create a form programmatically, and the output is dictated by the form class itself, or maybe even templates. Having complete control over the template is important for me, as I often work with designers on side jobs and they always want 'precision' form design, example: First and Last name fields on the same row, Helper links, Icons, etc. This is especially true when you use a UI CRUD solution and later attempt to theme it and move fields around with CSS.
Well for forms which is the heart of CRUD I obviously think the solution that Luke and I came up with for Skeleton is the most balanced solution. I think Luke has since forked a customized version that he uses and the Skeleton one has been enhanced as well to extend the idea to a form model. The design trade-off was that simple forms are a little harder to build, but complex forms are a lot easier. It is very much a solution that uses templates but can generate form fields. (also in the biased opinion section is the Pagination library that allspiritseve and I designed ;))

The direction that I think is interesting (but I have not done much with) is this idea of PHP generating JSON data for a Javascript form library to manage. The PHP still needs to receive, filter, validate and save the submitted data. But it seems like a Javascript solution would allow 1) presentation enhancements independent of the Model, 2) moving form generation and some processing to the browser, 3) allowing for fancy forms functionality and eye-candy like date (and other data) pickers, live search, lazy loaded selects, etc.
(#10850)
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: CRUD-S base controller

Post by alex.barylski »

CRUD record editing is sometimes called a Grid these days.
I'll have to Google that :)
The direction that I think is interesting (but I have not done much with) is this idea of PHP generating JSON data for a Javascript form library to manage. The PHP still needs to receive, filter, validate and save the submitted data. But it seems like a Javascript solution would allow 1) presentation enhancements independent of the Model, 2) moving form generation and some processing to the browser, 3) allowing for fancy forms functionality and eye-candy like date (and other data) pickers, live search, lazy loaded selects, etc.
I agree, only issue I have with that, is JS still isn't enabled on some mobile devices, such as my BB Curve. I was actually looking for a JS Forms builder, do you know of any projects?

Cheers,
Alex
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: CRUD-S base controller

Post by josh »

alex.barylski wrote:I have yet to find/discover a solution I felt good about. Part of the problem is with form creation. You create a form programmatically, and the output is dictated by the form class itself, or maybe even templates. Having complete control over the template is important for me, as I often work with designers on side jobs and they always want 'precision' form design, example: First and Last name fields on the same row, Helper links, Icons, etc. This is especially true when you use a UI CRUD solution and later attempt to theme it and move fields around with CSS.
With Zend_Form this is no way inhibited. You can use a view script for the form's markup if desired, as you pointed out. Putting fields on the same line is a CSS thing though and does not require editing markup. Re-use of forms goes far further than simply not having to duplicate it for update/create. Imagine how many times you ask for addresses in an application, as part of larger forms you may ask for addresses of various things. Forms can be snapped together like building blocks, re-using not only the form itself but all validation rules. By creating your own decorators you can change markup site wide, or even output json serializations of the validations, so a client side script can do it's own validation as well.
Post Reply