Professional CodeIgniter, Thomas Myer

Chapter 7: Improving the Dashboard
190
<
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 "
&
nbsp;";
$data = array(`name'=
>
'grouping','size'=
>
'10');
echo "Grouping: ". form_input($data);
echo form_submit("submit","batch update");
echo "
<
/p
>
";
echo "
<
table border='1' cellspacing='0' cellpadding='3' width=
'500'
>
\n";
echo "
<
tr valign='top'
>
\n";
echo "
<
th
>
&
nbsp;
<
/th
>
<
th
>
ID
<
/th
>
\n
<
th
>
Name
<
/th
>
\n
<
th
>
Status
<
/th
>
\n
<
th
>
Actions
<
/th
>
\n";
echo "
<
/tr
>
\n";
foreach ($products as $key =
>
$list){
echo "
<
tr valign='top'
>
\n";
echo "
<
td align='center'
>
".form_checkbox(`p_id[]',$list[`id'],FALSE)."
<
/td
>
";
echo "
<
td
>
".$list[`id']."
<
/td
>
\n";
echo "
<
td
>
".$list[`name']."
<
/td
>
\n";
echo "
<
td align='center'
>
".$list[`status']."
<
/td
>
\n";
echo "
<
td align='center'
>
";
echo anchor(`admin/products/edit/'.$list[`id'],'edit');
echo " | ";
echo anchor(`admin/products/delete/'.$list[`id'],'delete');
echo "
<
/td
>
\n";
echo "
<
/tr
>
\n";
}
echo "
<
/table
>
";
echo form_close();
}
?
>

Essentially, the form at the top of the view will post to a new controller function called
batchmode()
.
The form will pass in an array of product IDs (captured from the
p_id

checkbox array), a category ID
(from the category dropdown), and a grouping label (from the text field).

The important thing here is that each product ID embedded in a checkbox matches the product ID you ' re
dealing with. This is easily handled by simply adding the checkbox as you loop through the
$products

array.

The grouping field is very simple -- just give the user a little bit of space to type in a text string. You ' ll
use that text string (along with a selected
category_id

) to update the products database.
c07.indd 190
c07.indd 190
6/10/08 5:36:36 PM
6/10/08 5:36:36 PM


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

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

OK

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