/** * @param CategoryForm $form */ public function formSubmitted(CategoryForm $form) { try { $this->categoryManager->update($form->getValues()); $form->presenter->flashMessage('Category management was successful', 'success'); } catch (\Nette\InvalidArgumentException $ex) { $form->addError($ex->getMessage()); } }
public function actionUpdate($id) { $model = new CategoryForm(); if (isset($_POST['CategoryForm'])) { $model->attributes = $_POST['CategoryForm']; if ($model->validate()) { $model->save(); $this->redirect(array('index')); } } else { $model->loadDataFromCategory($id); } $statuses = array(0 => Yii::t('common', 'Disabled'), 1 => Yii::t('common', 'Enabled')); $stores = CHtml::listData(Store::model()->findAll(), 'store_id', 'name'); $stores[0] = Yii::t('store', 'Default'); $this->render('update', array('model' => $model, 'stores' => $stores, 'statuses' => $statuses)); }
public function createAction() { $form = new CategoryForm(); $category = new Category(); $data = $this->request->getPost(); if (!$form->isvalid($data, $category)) { foreach ($form->getMessages() as $message) { $this->flash->error($message); } return $this->forward("category/new"); } if (!$category->save()) { foreach ($category->getMessages() as $message) { $this->flash->error($message); } return $this->forward("category/new"); } $form->clear(); $this->flash->success("提交成功"); return $this->forward("category/index"); }
public function put_update() { $category = Category::find(Input::get('id')); if (!$category) { return Redirect::to_action('categories@index'); } # Set id to ignore on unique rules CategoryForm::set('current_id', $category->id); if (!CategoryForm::is_valid()) { return Redirect::back()->with_input()->with_errors(CategoryForm::$validation); } $category->name = Input::get('name'); $category->save(); return Redirect::to_action('categories@index'); }
public static function categories_tree($categories = null, $selected = null, $depth = 0) { if ($categories != null && is_array($categories)) { echo '<ul id="cat' . $categories[0]['fk_i_parent_id'] . '">'; $d_string = ''; for ($var_d = 0; $var_d < $depth; $var_d++) { $d_string .= " "; } foreach ($categories as $c) { echo '<li>'; echo $d_string . '<input type="checkbox" name="categories[]" value="' . $c['pk_i_id'] . '" onclick="javascript:checkCat(\'' . $c['pk_i_id'] . '\', this.checked);" ' . (in_array($c['pk_i_id'], $selected) ? 'checked="checked"' : '') . ' />' . ($depth == 0 ? '<span>' : '') . $c['s_name'] . ($depth == 0 ? '</span>' : ''); CategoryForm::categories_tree($c['categories'], $selected, $depth + 1); echo '</li>'; } echo '</ul>'; } }
CategoryForm::apply_changes_to_subcategories($category); ?> <span><?php _e('Apply the expiration date to children categories'); ?> </span></label> <?php } ?> </div> </div> </div> <div class="grid-row grid-70 no-bottom-margin"> <div class="row-wrapper"> <?php CategoryForm::multilanguage_name_description($locales, $category); ?> </div> </div> <div class="clear"></div> </div> <div class="form-vertical"> <div class="form-actions"> <input type="submit" class="btn btn-submit" value="<?php echo osc_esc_html(__('Save changes')); ?> " /> <input type="button" class="btn btn-red" onclick="$('.iframe-category').remove();" value="<?php echo osc_esc_html(__('Cancel')); ?> " />
/** * Prints category select * * @return void */ function osc_categories_select($name = 'sCategory', $category = null, $default_str = null) { if ($default_str == null) { $default_str = __('Select a category'); } CategoryForm::category_select(Category::newInstance()->toTree(), $category, $default_str, $name); }
</div> <div class="separate-top"> <div class="form-label"> <a href="javascript:void(0);" onclick="checkAll('cat_tree', true) ; return false ;"><?php _e('Check all'); ?> </a> · <a href="javascript:void(0);" onclick="checkAll('cat_tree', false) ; return false ;"><?php _e('Uncheck all'); ?> </a> </div> <div class="form-controls"> <ul id="cat_tree"> <?php CategoryForm::categories_tree($categories, $selected); ?> </ul> </div> </div> </div> <div id="advanced_fields_iframe" class="custom-field-shrink"> <div class="icon-more"></div><?php _e('Advanced options'); ?> </div> <div id="more-options_iframe" class="input-line"> <div class="form-row" id="div_field_options"> <div class="form-label"><?php _e('Identifier name');
/** * Save changes to a category. */ function updateCategory($args, &$request) { $categoryId = $request->getUserVar('categoryId') === null ? null : (int) Request::getUserVar('categoryId'); if ($categoryId === null) { $this->validate(); $category = null; } else { $categoryId = (int) $categoryId; $this->validate($categoryId); $category =& $this->category; } $this->setupTemplate($request, $category); import('classes.journal.categories.CategoryForm'); $categoryForm = new CategoryForm($category); $categoryForm->readInputData(); if ($categoryForm->validate()) { $categoryForm->execute(); Request::redirect(null, null, 'categories'); } else { $templateMgr =& TemplateManager::getManager(); $templateMgr->append('pageHierarchy', array(Request::url(null, 'admin', 'categories'), 'admin.categories')); $templateMgr->assign('pageTitle', $category ? 'admin.categories.editTitle' : 'admin.categories.createTitle'); $categoryForm->display(); } }
public static function plugin_categories($categories = null, $selected = null, $depth = 0) { if ($categories != null && is_array($categories)) { $d_string = ''; for ($var_d = 0; $var_d < $depth; $var_d++) { $d_string .= " "; } echo '<div id="cat' . $categories[0]['fk_i_parent_id'] . '">'; foreach ($categories as $c) { echo $d_string . '<input type="checkbox" name="categories[]" value="' . $c['pk_i_id'] . '" onclick="javascript:checkCat(\'' . $c['pk_i_id'] . '\', this.checked);" ' . (in_array($c['pk_i_id'], $selected) ? 'checked' : '') . '>' . ($depth == 0 ? '<span style="font-size:25px">' : '') . $c['s_name'] . ($depth == 0 ? '</span>' : '') . '</input><br />'; CategoryForm::plugin_categories($c['categories'], $selected, $depth + 1); } echo '</div>'; } }
"> <label for="categories"><?php _e("Preset categories"); ?> </label><br /> <a style="font-size: x-small; color: gray;" href="#" onclick="checkAll('frm3', true); return false;"><?php _e("Check all"); ?> </a> - <a style="font-size: x-small; color: gray;" href="#" onclick="checkAll('frm3', false); return false;"><?php _e("Uncheck all"); ?> </a> </td> <td> <?php CategoryForm::plugin_categories($categories, $selected); ?> </td> </tr> </table> </p> <p> <input class="Button" type="button" onclick="window.history.go(-1);" value="<?php _e('Cancel'); ?> " /> <input class="Button" type="submit" value="<?php _e('Update'); ?> " /> </p>