Professional CodeIgniter, Thomas Myer

Chapter 6: Creating a Dashboard
174
Figure 6-10


Creating the Product Edit Page
The
edit()

function of the admin/products controller is pretty much a clone of the
create()
process,
except that you have to load in the existing product information. Without further ado, here ' s the
edit()

function itself:
function edit($id=0){
if ($this-
>
input-
>
post(`name')){
$this-
>
MProducts-
>
updateProduct();
$this-
>
session-
>
set_flashdata(`message','Product updated');
redirect(`admin/products/index','refresh');
}else{
$data[`title'] = "Edit Product";
$data[`main'] = `admin_product_edit';
$data[`product'] = $this-
>
MProducts-
>
getProduct($id);
$data[`categories'] = $this-
>
MCats-
>
getCategoriesDropDown();
$this-
>
load-
>
vars($data);
$this-
>
load-
>
view(`dashboard');
}
}

c06.indd 174
c06.indd 174
6/10/08 5:36:06 PM
6/10/08 5:36:06 PM


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

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

OK

Loading...
...
Закрыть