Home Forums Add-ons Repeater Field Why not a JSON field ?


Why not a JSON field ?

  • Hi,
    This is not an issue, it is more our of curiosity and me trying to understand how ACF works.

    So I was checking how ACF stores the data in the database and I wonder why it is not using just a json field, specially because with the repeaters the input can be dynamic.
    #Section: How is the data saved?

  • I am not the developer but I know some of what went into this decision. ACF uses built in WP functions for saving data and it also allow you to use built in WP functions to get the data if you choose to do so.

    If the data was stored as JSON then you could not use get_sub_field() this function is a wrapper for built in functions like get_post_meta().

    The decision was made so that built in WP functions can be used and also be able to know what data in belongs in each row.

    ACF does what we can do using built in WP functions, it just makes it easier to build the admin fields.

    ACF is also recursive, saving a sub field in a repeater works exactly the same a saving a field at the top level. If sub fields worked differently than top level fields then there would need to be different code for sub fields removing the ability to nest repeaters indefinitely.

    Those are just some of the reasons

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.