I'm still getting used to cakePHP and the MVC, and I had a question
about good practices when updating an element on a page with an Ajax
action.

Currently I have $ajax->observeField() watching the fields of my form,
checking to see that the information the user types in is valid. The
data is checked by a custom action in my controller: validateField().
Since this is an action, it necessarily needs a view whenever the
action is called. As it is, the view file, valid_field.ctp, contains
code that will display the appropriate validation message after the
action has run. This information in valid_field.ctp is then inserted
(via the 'update' option) back into the original form that contains
the form.

This doesn't strike me as good practice, because it seems like I'm
inserting one view inside of another.

Should I use an element instead? Or, even more different, is it better
to have the actual 'add' action somehow provide the Ajax validation
and update the appropriate div? (Which would complicate things because
then my add view, add.ctp would have to intelligently distinguish
which error message to display inside of each error_message <div>).

So, when you have an Ajax specific request, what's best practice? Do
you make a call to an ajax specific function? And then that Ajax
function has it's own view file?

I think I'm missing something simple. I've browsed around the forums
and documentation quite a bit, but there isn't really an example of
best practices for Ajax and keeping consistent with MVC.

Thanks for the help --
--~--~---------~--~----~------------~-------~--~----~
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