abmcr Posted June 29 Posted June 29 I would like to order the display of a repeater in the backend on the basis of a field in it; my repeater is called dates_events and contains a title field and a date_event field. How can I display the values in admin by sorting by dates_events? I have tried with a hook but this does not work the date_event is a date/time field $wire->addHookAfter('InputfieldRepeater::render', function(HookEvent $event) { $inputfield = $event->object; if ($inputfield->name === 'date_events') { $inputfield->value = $inputfield->value->sort('data_event'); } }); Thank you in advance
virtualgadjo Posted June 30 Posted June 30 Hi, i use thie on musicians and bands websites and it works quite well (in the ready.php file) $this->addHookAfter('FieldtypeRepeater::wakeupValue', function($event) { $field = $event->arguments('field'); if($field->name !== 'date_events') return; $pa = $event->return; $pa->sort("date_event"); $event->return = $pa; }); you could of course easily choose to order by reverse chronological order using $pa->sort("-date_event"); hope it will be a little useful 🙂 have a nice day 2
abmcr Posted June 30 Author Posted June 30 Thank you this work fine 1 hour ago, virtualgadjo said: Hi, i use thie on musicians and bands websites and it works quite well (in the ready.php file) $this->addHookAfter('FieldtypeRepeater::wakeupValue', function($event) { $field = $event->arguments('field'); if($field->name !== 'date_events') return; $pa = $event->return; $pa->sort("date_event"); $event->return = $pa; }); you could of course easily choose to order by reverse chronological order using $pa->sort("-date_event"); hope it will be a little useful 🙂 have a nice day
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now