I'm using an Entityform to create a survey for a client, however one of the types of question they have is to rank a number of options in terms of importance to the user.

Similar to how the draggableviews module work would be the ideal, but I know that draggableviews changes the global setting for that list, rather than a per-user response.

Is there any way to achieve something like this?


Could you use "tabledrag", the code draggableviews uses to do dragging? It is basically javascript acting on an html table, with a weights column to remember the order.

Have a look at how the block module uses it (but bear in mind block is more complex because it has multiple regions to manage).

For tabledrag to work you need your questions in the form of a html table, which you then extend using the render array "#type" = "tabledrag". It is possible to configure tabledrag in Javascript, too.

  • But that wouldn't record the order the user puts it in, would it? Unless I have a hidden field which records the weight and I can track the weight per row – Andrew Morris May 15 at 9:44
  • tabledrag requires a normally-hidden field, which is normally called 'weight', to record the ordering. To use tabledrag in a form, though, you would need to include a method of submitting the order. I would suggest a hidden form input field which is updated by javascript - either monitoring the table's DOM or something else - and saves the weight column as a list of values. – rivimey May 15 at 9:48

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.