Hi Everyone,
I am working on building a form builder module for the past three days
and Ive finally reached the part that I was avoiding slightly - the
form building bit :) simply cause I am yet to come up with an
interesting way to do this without screwing it up.
Note -  I have already done the UI (JS, CSS) that builds the form but
I am not using JS to create the form elements but am rather using a
controller to do this with my JS simply handing the ajax and the
effects (jquery).

This is what Ive done to build the form -
I have 2 methods in my controller - renderelement and renderproperty.
If the user clicks on say "textbox" on the UI, I send an ajax request
that runs the renderelement method which basically sends back the html
rendering of the form element. If the user clicks on this form element
I do another ajax request and the renderproperty sends back the
element properties html markup (title, required, size, etc) which are
basically the properties of the form element that the user can then
customize.

I have the following questions -
1. I use a switch case inside these methods that handle what form
element is being requested for and sends back an appropriate response.
I do NOT like using switch cases and did this cause I wanted to show a
quick proto to my manager ;). Is there a better way to do this? I had
the following ideas (please tell me yours)
     a. Use partials/elements to render each form element and then in
the controllers view use something like $this->element('forms/' .
$type, $label); to do the rendering.
     b. Create a component class that does the rendering (it has
createTextbox etc methods)
     c. Use the FormHelper (cake's helper) to build the form elements
     d. Create classes for each form element - this is where I'd also
put in the JS validation rendering functions
This is the first time I am using cake and well I want to do it right.
I am slightly confused as to how my mentioned 4 alternative methods
can help my code be more maintainable and less coupled so I want to
know how people do this kind of thing.

Please help. Your suggestions will be most valued.

Thanks
Paul

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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