How to get row weights from a form before saving? I have form with an image upload field which saves multiple images. User can reorder and crop images in that form. Reorder using default drag option.

My requirement is to create a PDF of images in current order when user clicks on submit button.
I am taking the image uri from field values by loading node. So the order will be the saved order. I am creating the PDF inside hook_insert.

How do I get the row weights before saving the node, so PDF can be created according to current order of images?
You don't need to do anything special to get the row weights for the images.

The "weight" or list order of the images is stored in the delta value.

e.g:

$node-&gt;field_images[LANGUAGE_NONE][0]['fid'];
$node-&gt;field_images[LANGUAGE_NONE][1]['fid'];
$node-&gt;field_images[LANGUAGE_NONE][2]['fid'];


The delta value is 0, 1 &amp; 2 representing the first, second and third images respectively.

Also, if you're using one of the node API hooks, e.g hook_node_insert, you won't need to load the node, it should already be passed as a parameter there.