break; // Display form to edit a category // Display form to edit a category case 'rqEdit': $category = new claroCategory(); if ($category->load($id)) { $dialogBox->form($category->displayForm()); } else { $dialogBox->error(get_lang('Category not found')); } break; // Edit a new category // Edit a new category case 'exEdit': $category = new claroCategory(); $category->handleForm(); if ($category->validate()) { $category->save(); $dialogBox->success(get_lang('Category modified')); } else { if (claro_failure::get_last_failure() == 'category_duplicate_code') { $dialogBox->error(get_lang('This code already exists')); } elseif (claro_failure::get_last_failure() == 'category_self_linked') { $dialogBox->error(get_lang('Category can\'t be its own parent')); } elseif (claro_failure::get_last_failure() == 'category_child_linked') { $dialogBox->error(get_lang('Category can\'t be linked to one of its own children')); } elseif (claro_failure::get_last_failure() == 'category_missing_field') { $dialogBox->error(get_lang('Some fields are missing')); } $dialogBox->form($category->displayForm()); }