Drupal : Creating Form with Drag and Drop Ordering

drupal form with drag and drop ordering

So you want to create a form with drag and drop ordering in Drupal 7? Here are 3 simple steps to create a form with drag and drop ordering:

1. Implement hook_menu, to register the URL of the form

We will use the following function to render the form:

2. implement hook_theme, to register theme implementation of form with drag and drop support

And here is the callback function which will render the form with drag and drop capabilities

3. Implement hook_submit, to handle form submit and save the ordering

The code is quite long but you can just copy and paste then modify it if necessary. This tutorial is based on Ki Kim’s post on http://www.urbaninsight.com/2012/09/11/creating-table-with-draggable-weights-in-drupal-7 

Leave a Comment

Your email address will not be published. Required fields are marked *