Hi Jon, Dardo

I guess it depends how hacky you want to be. You could have two models
one that manages the form builder and another which is really just a
shell that would validate the actual forms when you submit them.

Off the top of my head I guess you could do something like this (not
tried out btw):

class FormsController extends AppController {

        var $name = 'Forms';

        /**
        * a generic method to handle the submited forms
        * looks up a schema / and validation rules based on the id of the
formthis-
        */
        submit_handler(){

                if(isset($this->data)){

                        $id = $this->data['Form']['id'];
                        // get all the data about the form
                        $meta = $this->Form->read(null, $id)
                        // set the validation array we want to use
                        $this->Form->validate = $meta['validation_rules'];

                        if ($this->Form->validates()) {
                                // it validated logic
                        } else {
                                // didn't validate logic
                        }
                }
        }
}

You would have to feed the model a schema (for the submitted form) to
use wouldn't you? Not sure how to do that but I'm sure it wouldn't be
hard to find out, (and I'd better do some work now!)

Cheers

On Nov 18, 3:02 pm, "Jon Bennett" <[EMAIL PROTECTED]> wrote:
> Hi Flip flops,
>
> >  Passing the schema and validation rules seems like a good idea - I'm
> >  guessing your are thinking you could couple it with some kind of
> >  wizard / interface so you build your forms within the CMS... could be
> >  a really goood feature but at the end of the day it boils down to how
> >  long the initial development time takes to recoup.
> >  Hi Flipflops,
> >  Passing the schema and validation rules seems like a good idea
>
> so did I - but I've just realised that my 'EmailForm' model would have
> it's own schema, at least:
>
> - id
> - name
> - schema
> - rules
>
> I'll need to add to this, either using a merge or just replacing the
> array - so that when adding a record to the CMS the real schema and
> validation are used, but when a form is submitted the custom schema
> and rules are used.
>
> Perhaps a simple check to see if there's any info in the 'with' of the
> habtm, if there is use the form rules, if not use the default.
>
> again though you have the issue of how/when/and by what this info is set.
>
> hmm - it's not obvious which way to go (yet!).
>
> Cheers,
>
> Jon
>
> --
>
> jon bennett
> w:http://www.jben.net/
> iChat (AIM): jbendotnet Skype: jon-bennett
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to