Professional CodeIgniter, Thomas Myer

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();
c07.indd 225
c07.indd 225
6/10/08 5:36:51 PM
6/10/08 5:36:51 PM


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.