Very cool Louis and Henrik, good stuff. I have some questions and some ideas. I
know you're concentrating on 3.0 now, don't want to monopolize your time, but
this relates very much to some things I've been thinking about, and I wanted to
touch base before possibly getting involved. Nothing here should be taken as
criticism of FormDaddy, quite the contrary, I very much like where it's going,
and it inspired me to put down some of my ideas.
I'm also very much not talking only to Louis, though I'd love to hear his
thinking on it, but also to anyone else who's interested. This is a long post,
apologies in advance.
Re FormDaddy specifically:
- I'd expect all values to be HTMLEditFormat encoded. Is there a philosophical
reason why that wasn't done, or is this just an early version?
- Either I don't understand something, or the radio widget is unfinished. First,
the renderer doesn't have logic to check itself or not, or a variable for the
active value, as opposed to the value for this individual radio button.
Second, radios are really only useful as a set, and I don't see a convention
or other way to provide a collection of values and display values.
Did you have a design somewhere (in your heads maybe?) that addresses these
issues?
A simple convention that looks for an array of value=displayValue strings in
rc.<fieldname>_options might be fine.
- Related, widgets to render HTML selects and multiple checkboxes would be
useful too. They'd need similar infrastructure to provide a collection of
available options. I'd suggest that both checkboxes and radios assume that they
are or may be multiple, rather than having separate multi-checkbox and
multi-radio types.
- The ability to pass in an errors collection would be very useful, to redisplay
a form with error messages displayed and invalid fields highlighted. An array of
errors in {highlightID: message} format might make sense.
Thinking about the big picture of a full generic CRUD tool, I'm thinking about
handler code something like this, assuming the various 'Daddy' plugins are DI'd
in:
// UserRole.list:
ListDaddy.list('UserRole');
// UserRole.edit:
FormDaddy.edit('UserRole', rc.UserRoleID);
// UserRole.save
errors = ServiceDaddy.save('UserRole', rc);
if(ArrayLen(errors))
FormDaddy.edit('UserRole', rc.UserRoleID, errors);
else
setNextEvent('UserRole.list');
// UserRole.delete
errors = ServiceDaddy.delete('UserRole', rc.UserRoleID);
if(ArrayLen(errors))
// tell user and display something
else
setNextEvent('UserRole.list');
The idea is to provide a high level of syntactic sugar for building CRUD areas
with minimal code, while maintaining healthy MVC separation, and allowing enough
control that the tools could be used in not-completely-standard situations.
In that light, there are some other components that would be good to have I
think:
- A generic list rendering tool analguous to FormDaddy
Many of the overall and field/column configuration options would be the same,
some not. For instance, list columns don't need validation, but do need
alignment.
It should be possible for a custom column rendering UDF to access the values
from multiple fields, and I'm not sure how to arrange that.
Another helpful config would be a headerUDF, which could be used to render a
search form or other custom HTML above the list. Possibly a footerUDF would be
useful too.
- A generic service to manage the actual save and delete operations
The save tool should validate first, and return an array or errors if invalid
fields are found. Personally, I don't think validation belongs at the view
layer; it's a model function, especially important if you expose an abstract API
that may be accessed without involving your app's forms at all.
There are of course pluses to client-side validation, and I don't want to
start a big discussion here about the pros and cons of ajax submits and other
alternative strategies. The big thing here I think is that validation specs
shouldn't be localized to the form definition; see next point.
- A metadata service used by the above components for configuration and defaults
All these operations need much of the same metadata -- table and column/field
names and user-friendly labels, PK column name, FK column names and related
tables and PK columns, etc.. Assuming we can't just abstract all this away with
CF9 ORM, which is currently the case for folks using Railo (including me for
some projects), it would be great to provide a central metadata service that
these other plugins, and possibly others in the future, could access.
Ideally the underlying data it works from could be initialized from existing
beans and/or a datasource, then customized from there. In simple cases, the
defaults would be fine.
This sounds very related to Transfer, if I'm not mistaken (which I easily
could be since I've only just started looking at it and have never used it).
However, though Transfer uses this sort of metadata internally, and ColdBox has
tools to build default configs, I didn't see how to ask Transfer for that info,
and these services would need additional info.
Are there other projects that would be better suited to this? I'm also not
sure how to both leverage existing technologies and extend them for this
purpose. Any thoughts?
I know that's an ambitious collection of ideas. What do folks think about all
this?
I'm very willing to get involved here myself, but as I said, I wanted to see
what others have to say, esp FormDaddy's daddies.
Dave