Support

Account

Home Forums Add-ons Repeater Field Display subfield from repeater fields in custom field

Helping

Display subfield from repeater fields in custom field

  • Hello,
    I’m trying to do something specific and I’ve tried to google it but I couldn’t find anything useful so far.

    I have a custom post type called “Itinerary” with a lot of custom fields including a repeater field “day_repeater” and a nested repeater “accommodations” with a subfield “status”. This looks something like this:

    Itinerary - custom fields

    Link to the image since it won’t show it with the img tag:
    http://tinyurl.com/y54vzh68

    There is also a tab called Status in this image.
    What I’m trying to do is to show all “status” subfields from the repeater field in this tab with the same values as in the repeater (basically clone them so that they show the values from each repeater).

    This will be used so that the client doesn’t have to open every repeater to see the status of the accommodation, he just needs to open the status tab and see for each day the status of the accommodation.

    Is this possible to accomplish and if yes could you point me in which direction I should go?

    I’ve searched for something similar but couldn’t find anything. From my point of view first I need to create a new field type in ACF (found this link: https://www.advancedcustomfields.com/resources/creating-a-new-field-type/), after that I should make a loop through the nested repeater and grab the values of the subfield “status” to display them in the new field type.

    Would be great if you can help me out with this one. 🙂

    Thank you in advance,
    Kristijan

  • Hi Kristjan,

    I see two way to do it depending on if you want your statut resume to be editable or not.

    If not : you can simply use the Enhanced Message Field plugin which allow you to put a ACF field containing HTML and PHP. In the field you’ll just have to get the post ID and use get_field and get_subfield to display the Kristijan resume as on front-end.

    If need it editable : I assume you can add a repeater field in the statut Tabs and use validate_value filter and prepare_field or load_value action to fill it. The validate_value filter on the resume statut field may allow you to synchro your first repeater.

    In the second case I haven’t the exact code solution because I never do the same but it’s a begining of help 🙂

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

The topic ‘Display subfield from repeater fields in custom field’ is closed to new replies.