"Next"/"Previous" buttons on form view

I have a customer who uses a simple module for recording data that needs 3rd party verification. So, one person enters the data resulting in a big list of records. The 2nd person then logs in and checks each record and marks it as validated in the form view.

Is it possible to add "next" and "previous" buttons on the form view toolbar to speed up navigation?



  • edited 2:30AM
    Form_builder has a property of "other_actions" property that you can leverage to create a button right next to your save button near the bottom of your form. This can be implemented in your model's form_fields method by using the special key of __FORM_BUILDER__ like so (note that you will need to implement the get_prev() and get_next() methods on your model:
    // make sure it's not a new record but one we are editing if (!empty($values['id'])) { $buttons = []; // Method you will need to implement to get next and previous IDs $prev_id = $this->get_prev($values['id']); $next_id = $this->get_next($values['id']); if ($prev_id) { $buttons[] = '<input type="button" value="Previous" id="previous" onclick="window.location="'.fuel_url('my_module/edit/'.$prev_id).'"/>'; } if ($next_id) { $buttons[] = '<input type="button" value="Next" id="previous" onclick="window.location="'.fuel_url('my_module/edit/'.$next).'"/>'; } if (!empty($buttons)) { $fields['__FORM_BUILDER__'] = array('other_actions' => implode('&nbsp; ', $buttons)); } }
  • Cheers. It was the get_prev() and get_next() I was hoping someone might have some insight on :)

    I guess the tricky bit would for the buttons to know what the sorting status of the list view was before they jumped into the form view.
  • edited 2:30AM
    The Fuel_blog module has a get_next_post and get_prev_post which you may want to look at. The difference being that it is using a date to determine the next and previous and you probably aren't.
Sign In or Register to comment.