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 doesn't allow custom fieldtypes to process data when inserting entries

September 10, 2010 4:29pm

Subscribe [5]
  • #1 / Sep 10, 2010 4:29pm

    ender

    1644 posts

    The channel entries API appears to just try to save whatever data you pass it directly into the appropriate channel_data fields without checking to see what type of custom field it is actually dealing with.  There are a growing number of add-ons that have their own database tables where they store the custom field data in a nicely indexed, organized, and searchable way.

    Right now any channel that has such a custom field is incompatible with the channel entries API, limiting its potential greatly. Is this issue on the radar? Considering that the fieldtypes adhere to your own API and the breakdown happens between two first-party APIs I’d consider this a bug.

    edit:
    it appears that the channel entries api submit_new_entry method actually attempts to call the post_save function for the custom fieldtypes. this gives me hope that this functionality is intended to work and just isn’t completely there yet… if it could call the third party fieldtype validate and save functions as well we might have something useful here 😊

  • #2 / Sep 11, 2010 2:27pm

    Greg Salt

    3988 posts

    Hi Ty,

    I have passed your comments on to the rest of the team and we will respond in due course.

    Cheers

    Greg

  • #3 / Sep 20, 2010 12:15pm

    Robin Sowell

    13255 posts

    ender- I’m a little fuzzy on how this is breaking down for you.  Can you walk me through an example perhaps?

  • #4 / Nov 02, 2010 12:44pm

    chichilatte

    43 posts

    I agree with Ty, this looks so close to being fixed, and really needs to be. When I try to submit a new entry containing a Playa field, Api_channel_entries->submit_new_entry() fails because it isn’t calling the Playa fieldtype’s save() method. The Playa data passed to submit_new_entry() looks something like this…

    Array
    (
        [old] => 
        [selections] => Array
            (
                [0] => 
                [1] => 5
            )
    
    )

    But Api_channel_entries produces the php error

    A PHP Error was encountered
    Severity: Notice
    Message: Array to string conversion
    Filename: mysql/mysql_driver.php
    Line Number: 535

    ...because the Playa fieldtype’s save() method isn’t given the chance to flatten the array.

    The bug seems to be in Api_channel_entries->_prepare_data(), which looks like it’s trying to call the save() method but isn’t for some reason.


    Should be a quick fix no, since the third-party fieldtypes are ready to handle the saving/validating/post_saving?

    [EE 2.1.0 build 20100810]

  • #5 / Nov 02, 2010 12:50pm

    chichilatte

    43 posts

    I think the clue is that the Content_publish->entry_form() method - responsible for saving new entries from inside the control panel - also uses Api_channel_entries->submit_new_entry(), but it somehow gets Api_channel_entries->_prepare_data() to call the fieldtypes’ save() method.

    NOTE: the Content_publish controller is at /system/controllers/cp/content_publish.php

  • #6 / Nov 03, 2010 4:43am

    John Henry Donovan

    12339 posts

    ender,

    What build and version are you using?

    chichilatte,

    Can you go ahead and upgrade to most recent version and build please so we are all on the same page.

  • #7 / Nov 03, 2010 11:23am

    chichilatte

    43 posts

    Just upgraded to the latest EE2.1.1, but had to regress back because my reverse_related_entries matrix fields stopped working :(

    Let me get back to you about all this when i can happily upgrade to the latest version.

    thanks
    chichi

  • #8 / Nov 03, 2010 5:18pm

    Ingmar

    29245 posts

    Very good, we’ll be here.

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

ExpressionEngine News!

#eecms, #events, #releases