protected function createComponentAddEdit($name) { $roles[0] = ' '; $mroles = new RolesModel(); $rows = $mroles->getTreeValues(); foreach ($rows as $key => $row) { // function array_merge does't work correctly with integer indexes // manual array merge $roles[$key] = $row; } $form = new AppForm($this, $name); $renderer = $form->getRenderer(); $renderer->wrappers['label']['suffix'] = ':'; //$form->addGroup('Add'); $form->addText('name', 'Name', 30)->addRule(Form::FILLED, 'You have to fill name.')->getControlPrototype()->onChange("create_key()"); $form->addText('key_name', 'Key', 30)->addRule(Form::FILLED, 'You have to fill key.'); $form->addSelect('parent_id', 'Parent', $roles, 15); $form->addTextArea('comment', 'Comment', 40, 4)->addRule(Form::MAX_LENGTH, 'Comment must be at least %d characters.', 250); if ($this->getAction() == 'add') { $form->addSubmit('add', 'Add'); } else { $form->addSubmit('edit', 'Edit'); } $form->onSubmit[] = array($this, 'addEditOnFormSubmitted'); }
protected function createComponentAddEdit($name) { $form = new NAppForm($this, $name); $access = array(1 => 'Allow', 0 => 'Deny'); // roles $mroles = new RolesModel(); $roles = $mroles->getTreeValues(); // resources $resources[0] = '- All resources -'; $mresources = new ResourcesModel(); $rows = $mresources->getTreeValues(); foreach ($rows as $key => $row) { // function array_merge does't work correctly with integer indexes // manual array merge $resources[$key] = $row; } // privileges $privileges[0] = '- All privileges -'; $rows = dibi::fetchAll('SELECT id, name FROM [gui_acl_privileges] ORDER BY name;'); foreach ($rows as $row) { // function array_merge does't work correctly with integer indexes // manual array merge $privileges[$row->id] = $row->name; } //$renderer = $form->getRenderer(); //$renderer->wrappers['label']['suffix'] = ':'; //$form->addGroup('Add'); $form->addMultiSelect('role_id', 'Role', $roles, 15)->addRule(NForm::FILLED, 'You have to fill roles.'); $form->addMultiSelect('resource_id', 'Resources', $resources, 15)->addRule(NForm::FILLED, 'You have to fill resources.'); $form->addMultiSelect('privilege_id', 'Privileges', $privileges, 15)->addRule(NForm::FILLED, 'You have to fill privileges.'); //$form->addSelect('access', 'Access', $access) $form->addRadioList('access', 'Access', $access)->addRule(NForm::FILLED, 'You have to fill access.'); $form->addSubmit('assign', 'Assign'); $form->onSuccess[] = array($this, 'addEditOnFormSubmitted'); }
protected function createComponentAddEdit($name) { $mroles = new RolesModel(); $roles = $mroles->getTreeValues(); $form = new AppForm($this, $name); $renderer = $form->getRenderer(); $renderer->wrappers['label']['suffix'] = ':'; //$form->addGroup('Add'); $form->addText('username', 'Name', 30)->addRule(Form::FILLED, 'You have to fill name.'); if ($this->getAction() == 'add') { $form->addPassword('password', 'Password', 30)->addRule(Form::FILLED, 'You have to fill password.'); $form->addPassword('password2', 'Reenter password', 30)->addRule(Form::FILLED, 'Reenter your password.')->addRule(Form::EQUAL, 'Passwords do not match.', $form['password']); } $form->addMultiSelect('roles', 'Roles', $roles, 15); if ($this->getAction() == 'add') { $form->addSubmit('add', 'Add'); } else { $form->addSubmit('edit', 'Edit'); } $form->onSubmit[] = array($this, 'addEditOnFormSubmitted'); }
protected function createComponentAddEdit($login) { $mroles = new RolesModel(); $roles = $mroles->getTreeValues(); $form = new NAppForm($this, $login); $renderer = $form->getRenderer(); $renderer->wrappers['label']['suffix'] = ':'; //$form->addGroup('Add'); $form->addText('login', 'login', 30)->addRule(NForm::FILLED, 'You have to fill login.'); $form->addSelect('activate', 'Aktivovany', array('1' => 'ano', 0 => 'nie')); // if ($this->getAction()=='add') { $form->addPassword('password', 'Password', 30)->addRule(NForm::FILLED, 'You have to fill password.'); $form->addPassword('password2', 'Reenter password', 30)->addRule(NForm::FILLED, 'Reenter your password.')->addRule(NForm::EQUAL, 'Passwords do not match.', $form['password']); // } $form->addMultiSelect('roles', 'Roles', $roles, 15); if ($this->getAction() == 'add') { $form->addSubmit('add', 'Add'); } else { $form->addSubmit('edit', 'Edit'); } $form->onSuccess[] = array($this, 'addEditOnFormSubmitted'); }