I'm creating a page where I have a bunch of entries I want to populate with jquery drag and drop boxes. It's for the arrangement of songs, just as a tool.

And I want to store the position of these in a JSON object. When I was using Expression Engine I managed to send an SQL command and store the data in the correct fields. Albeit it was kinda wonky.

But now I'm using Craft so I figure there might way better ways of doing stuff like this. Do I use a form? Do I hide that form and send it using AJAX every time I make some changes to the jquery drag and drop boxes?

enter image description here

  • 1
    What kind of field (or fields) is it on the back-end? How that data is being stored in the Craft CP will affect the answer. – Lindsey D Mar 20 '16 at 20:49
  • I haven't created any fields yet. But I imagine I'll have separate entries, with their own data in them. Just like any other blog site really. – Kenny Bones Mar 20 '16 at 20:57
  • What are the "things" that you're dragging & dropping? Are you rearranging the order of full entries? – Lindsey D Mar 20 '16 at 20:59
  • See my updated post :) As of now, I only add divs to a container, and then add jquery drag and drop and resize method on them. Nothing fancy yet. It's these divs that I want to store the information of, in the JSON object – Kenny Bones Mar 20 '16 at 21:03

It's a little tough to say, since you it seems like you haven't actually architected any of this in the Craft back-end yet. I encourage you to create a field (or fields) which would be a good container for this data.

Once you've established what kind of field you're using, you may find that there is a different answer... but based on your current intent to store a simple JSON object, it sounds like you'd be using a simple plain text field.

Assuming you're using a plain text field, this is actually quite simple to accomplish. Use your JavaScript to set the value of a hidden field, before submitting the form:

<input type="hidden" name="fields[songsJson]" value="" />

More info on saving entry data from a front-end form:


  • Right, so I can basically just store this stuff via an Ajax handler then? Sounds reasonable enough :) I haven't used forms Craft yet to this will be interesting to see if I can create a nice effect for the callback (if there is any). – Kenny Bones Mar 20 '16 at 21:13
  • Yup, it's pretty much just a plain container for your JSON. Out of curiosity, did you want that data to be useful on the back-end? A block of JSON data won't really be helpful in the control panel at all... I suspect there are better ways to architect that data. – Lindsey D Mar 20 '16 at 21:16
  • Actually, I couldn't care less about the back end on this project. I want to tie as much as possible up to the front end. The people who'll be using this are musicians and some of them have zero know how on computers in general. But it's interesting! :) – Kenny Bones Mar 20 '16 at 21:22
  • Alright, fair enough... plain text field it is! – Lindsey D Mar 20 '16 at 21:23

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.