Chapter 7: Improving the Dashboard
225
Figure 7-14
Adding Color and Size Checkboxes to Products
Now that the administrative screens for colors and sizes are all in, let ’ s add a set of simple interface
elements to the admin_product_create and admin_product_edit views. As soon as those two changes are
made, you will then need to update the backend processes to keep the products_sizes and products_
colors tables in sync.
First, open the admin/products controller and add two simple calls to the create() function. You want
to call getActiveColors() and getActiveSizes() from their respective models. You can then use the
data from those two calls to create checkboxes for colors and sizes inside the Create form.
function create(){
if ($this- > input- > post(‘name’)){
$this- > MProducts- > addProduct();
$this- > session- > set_flashdata(‘message’,’Product created’);
redirect(‘admin/products/index’,’refresh’);
}else{
$data[‘title’] = “Create Product”;
$data[‘main’] = ‘admin_product_create’;
$data[‘categories’] = $this- > MCats- > getCategoriesDropDown();