I am able to add/delete matrix blocks from within my plugin without any problems. I would like to give the user the ability to drag & drop any field just as you can within the CP.

I can use jQuery UI Sortable to create the functionality no problem. I am curious what/how to call within Craft that manages order so that it is saved.

Thank you for any suggestions!


Matrix blocks are saved in the order they appear in the POST data when saving the "owner" element (the entry, or whatever). So just adding jQuery Sortable to your front-end form will be enough.

| improve this answer | |
  • Ah - perfect thank you, Brandon! I wasn't sure if there was an additional call I needed to make. – Damon Apr 5 '16 at 13:39

You'd re-save the element with the field set to the re-ordered array of IDs representing the Matrix blocks.

You don't have to save the blocks themselves, just the element.

| improve this answer | |
  • Thank you, Carlcs - I have everything set up - I should have just given it a shot in the first place :) – Damon Apr 5 '16 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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