7.1. Batch Mode Operations
One of the more prominent items on the sprint backlog is allowing Claudia to assign categories and groupings to her products in batch mode. Access to such a tool would save her a lot of time, as the only way she can update these settings is by editing one product at a time.
The easiest way to add a batch mode process to the products home view is to make it into a form. You want to end up with one checkbox per product listing (using the product ID as the value of each checkbox), a dropdown list for category selection, and a text field that accepts a grouping string.
Once you have all that in the view, you'll create a specialized function in the products controller and a corresponding model function that will handle the updates for you. Then, all you have to do is post the form to that specialized controller function, and you have a batch mode operator!
In the following code, the form elements have been placed inside admin_products_home view. The bold lines represent new code.
<h1><?php echo $title;?></h1> <p><?php echo anchor("admin/products/create", "Create new product");?> <?php if ($this->session->flashdata('message')){ echo "<div class='message'>".$this->session->flashdata('message')."</div>"; } if (count($products)){ echo form_open("admin/products/batchmode"); echo "<p>Category: ". form_dropdown('category_id',$categories); echo " "; $data = array('name'=>'grouping','size'=>'10'); echo "Grouping: ". form_input($data); echo form_submit("submit","batch ...
Get Professional CodeIgniter® now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.