1

I am trying to update a specific row in a matrix field using a frontend form, I created them using another form with each row following the [new1], [new2] etc. naming format, but I can't seem to get it working using the code below

{% for block in entry.fieldOrderItemsMatrix.all() %}
    <form method="post" accept-charset="UTF-8">
      {{ csrfInput() }}
      {{ actionInput('entries/save-entry') }}
      {{ hiddenInput('sectionId', craft.app.sections.getSectionByHandle('orders').id) }}
      {{ hiddenInput('entryId', entry.id) }}
      <input type="checkbox" name="fields[fieldOrderItemsMatrix][new{{ loop.index }}][fields][fieldOrderDelivered]" {{ delivered ? 'checked' }}>
      <span>Delivered</span>
      <button>Save</button>
    </form>
{% endfor %}

1 Answer 1

1

You only use new1, new2 etc for creating new matrix blocks during the submission. For editing existing blocks, you need to use the block's ID in that same place. In your case that would be block.id.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.