public function add() { $argumentarray = Router::$arguments; //$id = $argumentarray[0]; if (isset($_POST['save'])) { $post = new Validation(array_merge($_POST, $_FILES)); $post->pre_filter('trim', 'foilName', 'foilHexcode'); $post->add_rules('foilName', 'required'); $post->add_rules('foilHexcode', 'required'); if (!$post->validate()) { $errors = $post->errors('form_errors'); foreach ($errors as $error) { echo '<p class="error">' . $error . '</p>'; } } else { //$id = $argumentarray[0]; $foils = new Foil_Color_Model(); $foil = ORM::factory('foil_color'); $foil->name = $post->foilName; $foil->hexcode = $post->foilHexcode; try { $foil->save(); $foils = new Foil_Color_Model(); $id = $foils->getNextID(); url::redirect('/foils/edit/' . $foil->id); } catch (Exception $ex) { echo 'There was an error adding this foil: ' . $ex->getMessage(); //url::redirect('/foils/'); } } } $this->_renderView(); }
<div id="tab_foils" > <div class="headline">Foils</div> <table> <colgroup> <col width="150" /> <col /> </colgroup> <tr> <td><label for="metaTitle">Name</label></td> <td><label for="metaTitle">Color</label></td> </tr> <?php foreach ($productcolors as $productcolorid) { $cid = $productcolorid->colorID; $colorsmodel = new Foil_Color_Model(); $color = $colorsmodel->getFoilByID($cid); //foreach($colors as $color){ echo '<tr>'; echo '<td><label for="flavorName">' . $color->name . '</label></td>'; echo '<td><label for="flavorColor">' . $color->hexcode . '</label></td>'; echo '</tr>'; //} } ?> </table> </div> <!-- div id="tab_costs" --> <div id="tab_flavors" >
{ // Automatically calculates the editor base path based on the _samples directory. // This is usefull only for these samples. A real application should use something like this: // oFCKeditor.BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value. var sBasePath = '<?php echo url::base(); ?> /media/js/fckeditor/'; } </script> <?php $argumentarray = Router::$arguments; $foils = new Foil_Color_Model(); if (isset($argumentarray[0])) { $id = $argumentarray[0]; $foil = $foils->getFoilByID($id); } else { //$id = $foils->getNextID(); $foil = ORM::factory('foil_color'); } $i = 0; $j = 0; ?> <form action="<?php if (isset($id)) {