• Resolved jeanius-design

    (@jeanius-design)


    Hi there,

    Apologies if I’m missing something fundamental here.

    How can I create a form that appends to a custom field instead of replacing?

    I have created a form without loading existing values. I have then added a custom action which adds a new row to a repeater field.

    The custom action does add the new row, but it replaces the field, so anything that was there before disappears.

    For context, I want to make a list of documents. The form should allow me to upload a new document to add to the list of existing ones without showing them all on the front end.

    Is this possible?

    Thank you.

Viewing 1 replies (of 1 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback!

    If you use the update_field() in to update your Repeater, it is normal that it “replaces” existing values. You should first get the existing value with get_field('my_repeater', false, false) and then append your row to the array.

    Please note that it is important to get the “unformatted” value when it is going to be used to update a field. Specifically for complex fields like the Repeater. This is why you should use the last false argument in the get_field(). See documentation.

    Hope it helps!

    Have a nice day!

    Regards.

Viewing 1 replies (of 1 total)
  • The topic ‘Appending items’ is closed to new replies.