A feature change to add new entity references to top of list instead of the bottom

Comments

Abirz created an issue. See original summary.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Ace Cooper’s picture

Version: 7.x-2.0-rc7 » 7.x-2.x-dev

Got the same request from our content manager this week.
We add anywhere from 10 to 500 items into the entityreference field, and sometimes we come back to add more later. So the idea was on the entity edit form to display the newly added items at the top of the table.

For this you only need a simple one line change.
Don't even think this deserves a patch, because it is quick and dirty.

Find the following line from function entityreference_view_widget_ajax in entityreference_view_widget.module:

$input_ids = array_merge($selected_entity_ids, $form_state['values']['entityreference_view_widget']);

and change the order of merging arrays:

$input_ids = array_merge($form_state['values']['entityreference_view_widget'], $selected_entity_ids);