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.

Channel entries api and field type validation

October 04, 2011 8:35am

Subscribe [4]
  • #1 / Oct 04, 2011 8:35am

    Andrew Weaver

    206 posts

    Hi,

    I’m using the channel entries api to add some entries and I’m finding that the Fieldtype validate method is not getting run for any of the fields.

    Should the validate function be called when the channel entries api is used, or is it only called when publishing through the Control Panel? It seems like some 3rd party add-ons use the validate method to do some crucial functionality.

    Thanks,
    Andrew

  • #2 / Oct 04, 2011 9:41pm

    Kevin Smith

    4784 posts

    Hi Andrew,

    I’m not actually sure of the answer here, so I’m going to ping Robin for some insight. Hang tight for me!

  • #3 / Oct 05, 2011 4:40pm

    Andrew Weaver

    206 posts

    Hi Kevin,

    Thanks for the reply.

    From my tests, the validate function doesn’t seem to be run (although I could be wrong). I think my question now is whether it should be running or not. If not, then it might be worth adding a note to the Fieldtype documentation because some of the ‘big’ field types seem to be using it process the data.

    Thanks again,
    Andrew

  • #4 / Oct 05, 2011 4:59pm

    Robin Sowell

    13255 posts

    The entries api isn’t designed to run the validation check itself (in part because of when it was written)- if you take a look at the content_publish controller, you’ll see validation is handled separately for custom fields, before it is passed on to the entries api.

    $this->_set_field_validation($this->_channel_data, $field_data);

    There is some validation of core variables handled in the API, but custom field validation will need to be handled separately.  Hope that clarifies.

  • #5 / Oct 05, 2011 5:11pm

    Andrew Weaver

    206 posts

    Hi Robin,

    Thanks for your reply - very much appreciated.

    I develop DataGrab - a data import module - which uses the api to add new entries. Some of the 3rd party fieldtypes I’ve been adding support for don’t work if the validation function is not called - the function seems to get used for other things because of where in the process it gets called.

    Thanks for clearing things up.

    Andrew

  • #6 / Oct 06, 2011 10:19am

    Robin Sowell

    13255 posts

    Ah- nice addon, btw!  Have used it myself in 1.x.

    The entry api was actually written before the custom fields were added, which likely sheds more light on why things work as they do.  Hope nothing in there proves too problematic for you!

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

ExpressionEngine News!

#eecms, #events, #releases