ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

SAEF Custom Error Handling

April 22, 2008 8:57pm

Subscribe [2]
  • #1 / Apr 22, 2008 8:57pm

    michaelb

    21 posts

    Hey everyone,

    I’m using SAEF to add posts to a weblog, and I wanted to know if I could customise the way that EE handles form errors (e.g. missing mandatory field). Currently once a form is submitted with errors, the user gets redirected to a white screen with a little gray box, where the user needs to click a button to change the form contents. What I want is to display the errors that EE delivers on the actual form, so there is one less step. I know I can handle most errors through JavaScript (and I probably will handle them through JS) but its not secure enough - you should always enable PHP error checking in case users disable JavaScript in their browsers.

    Any suggestions on how this is done? Can it be done without extensive custom code??

    —Michael—

  • #2 / Apr 22, 2008 9:24pm

    Jesse M

    92 posts

    Hey Michael,

    You may be able to hijack the process to suit your purposes by creating an extension that implements the weblog_standalone_insert_entry hook.  But I don’t know how easy it would be to accomplish what you want to do.  I think the way EE handles errors with this form—using JS to send the user back, instead of providing a way to repopulate the form data—is pretty hokey and I think figuring out how to repopulate the form will be your biggest challenge.  I have some general ideas where I’d get started looking into doing that, but assuming there’s even a workable solution, it might be what you’d consider extensive custom code.

    I’m thinking maybe you could do something like use that hook to mimic a page request (code for that is in system/core/core.system.php) to redisplay the form, and use a plugin to repopulate the form from POST data (that’s what I’m doing anyway to make the form function as an editing form) and show your error messages.

    Of course if you’re going to implement some JS error checking, then you can have it backed up by the built-in EE error checking and those users with JS disabled are the only ones who are going to be inconvenienced by that extra step.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases