protected function createComponentAddEdit($name)
{
$form = new AppForm($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 %n ORDER BY name;', TABLE_PRIVILEGES);
foreach ($rows as $row) {
// function array_merge does't work correctly with integer indexes
// manual array merge
$privileges[$row->id] = $row->name;
}
// assertions
$assertions = array('Choose') + dibi::fetchPairs('SELECT id, class FROM %n ORDER BY class', TABLE_ASSERTIONS);
//$renderer = $form->getRenderer();
//$renderer->wrappers['label']['suffix'] = ':';
//$form->addGroup('Add');
$form->addMultiSelect('role_id', 'Role', $roles, 15)->addRule(Form::FILLED, 'You have to fill roles.');
$form->addMultiSelect('resource_id', 'Resources', $resources, 15)->addRule(Form::FILLED, 'You have to fill resources.');
$form->addMultiSelect('privilege_id', 'Privileges', $privileges, 15)->addRule(Form::FILLED, 'You have to fill privileges.');
$form->addSelect('assertion_id', 'Assertion', $assertions);
//$form->addSelect('access', 'Access', $access)
$form->addRadioList('access', 'Access', $access)->addRule(Form::FILLED, 'You have to fill access.');
$form->addSubmit('assign', 'Assign');
$form->onSubmit[] = array($this, 'addEditOnFormSubmitted');
}