Пример #1
0
 }
 $s = $form->createElement('select', 'status_id', 'Access Level:', null, array('size' => '3', 'id' => 'access_level'));
 $s->loadArray($access_level_opts);
 $form->addElement($s);
 $form->addElement('html', '</fieldset>');
 $form->addRule('item', 'Please enter a title', 'required');
 // group rules
 $form->addRule('type_id', 'Please Select a menu type', 'nonzero');
 $form->addRule('status_id', 'Please Select a access level', 'nonzero');
 if ($form->validate()) {
     $menuBar = array();
     // Apply form element filters.
     $form->freeze();
     $values = $form->process(array(&$this, 'formValues'), false);
     $tree = new NestedTreeAdmin($this->registry->core . 'menu_items', null, 'item');
     $ip = end($tree->getTopLevelTree());
     $category_id = $tree->insert($ip['item_id'], $values, 'after child');
     $menuBar['back'] = '/menu/overview';
     // Always check that result is not an error
     if ($category_id) {
         $params['TYPE'] = 'pass';
         $params['MESSAGE'] = '<h2>Menu was successfully added.</h2>';
     } else {
         $params['TYPE'] = 'error';
         $params['MESSAGE'] = '<h2>Menu could not be added to the database.</h2>';
     }
 } else {
     $renderer = new UthandoForm(__SITE_PATH . '/templates/' . $this->get('admin_config.site.template'));
     $renderer->setFormTemplate('form');
     $renderer->setHeaderTemplate('header');
     $renderer->setElementTemplate('element');