Monday, April 4, 2011

Re: User/Admin definable forms (schemaless forms)

Look into EAV structures. Basically you build tables that map data
types (field types) to their values and the owning model by name and
id. A polymorphic behavior would do most of the work. There are a few
of on github that google finds pretty easily.

This of course doesn't do the form building work, or decide how to map
value types to input types etc. But it should give you something to
play with.
http://debuggable.com/posts/unlimited-model-fields-expandable-behavior:48428c2e-9a88-47ec-ae8e-77a64834cda3

On Apr 4, 7:52 pm, Greg Skerman <gsker...@gmail.com> wrote:
> Hi,
>
> I'm currently toying with the idea of a user definable form. This would
> allow a site administrator to create new forms to capture various data, and
> report on the data in the admin section.
>
> I've got the basic data structure, being a forms table, having many
> form_fields, each having one form_field_type, and storing information into
> form_field_responses
>
> There are 2 approaches I'm playing with to do this.
>
> Approach 1 would be a simple helper which can be used to autogenerate the
> form. This would require the data for the form structure to be passed to the
> view in each method.
>
> Approach 2 is to use a behavior with a generateForm method that overwrites
> $_schema (based on form_fields and form_field_type) to facilitate auto-form
> generation leveraging the form helper's inputs() method.
>
> anyone got any thoughts on the best approach for this sort of thing?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: