2

I'm working on a custom fieldtype that requires some validation via AJAX, which means I need an endpoint to direct my $.get() requests to. I know that accessories support process_x methods but fieldtypes don't appear to offer anything similar.

As far as I can see my options are to create a module (which otherwise I have no need for) or an extension (ditto, really). I noticed that the VZ URL fieldtype uses the sessions_start hook for this but that's not ideal as it's adding a little overhead to every single request, even frontend ones.

Is there a better, simpler option that I'm missing?

1 Answer 1

3

As far as i know, you cannot do this in a fieldtype in any other way. What i've seen most often is a accompanying module that registers an action so that the method in the module acts as the ajax endpoint.

That's not a huge amount of extra work thought is it really :)

I do fully appreciate what you're saying though, it's a shame it can't all be self contained in the fieldtype :(

4
  • Yep, I expect that's what I'll end up doing, but I thought I'd double check that there wasn't a better way. Cheers.
    – Dom Stubbs
    Feb 6, 2013 at 13:44
  • Fell free to tick my answer as the correct one ;) Feb 7, 2013 at 13:18
  • I've given in and setup a module but I was going to leave the question open for a few days just in case someone has got a cunning workaround that they've not posted yet. Adding process_x support for fieldtypes is such an obvious feature request but I'm not even sure where to post a FR these days.
    – Dom Stubbs
    Feb 7, 2013 at 15:15
  • Pick an ellislab employee, and do [email protected] Feb 7, 2013 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.