Exemplo n.º 1
0
 function form_addgroup()
 {
     $oForm = new KTForm();
     $oForm->setOptions(array('identifier' => 'ktcore.groups.add', 'label' => _kt("Create a new group"), 'submit_label' => _kt("Create group"), 'action' => 'creategroup', 'fail_action' => 'addgroup', 'cancel_action' => 'main', 'context' => $this));
     $oForm->setWidgets(array(array('ktcore.widgets.string', array('name' => 'group_name', 'label' => _kt("Group Name"), 'description' => _kt('A short name for the group.  e.g. <strong>administrators</strong>.'), 'value' => null, 'required' => true)), array('ktcore.widgets.boolean', array('name' => 'sysadmin', 'label' => _kt("System Administrators"), 'description' => _kt('Should all the members of this group be given <strong>system</strong> administration privileges?'), 'value' => null))));
     $oForm->setValidators(array(array('ktcore.validators.string', array('test' => 'group_name', 'output' => 'group_name')), array('ktcore.validators.boolean', array('test' => 'sysadmin', 'output' => 'sysadmin'))));
     // if we have any units.
     $aUnits = Unit::getList();
     if (!PEAR::isError($aUnits) && !empty($aUnits)) {
         $oForm->addWidgets(array(array('ktcore.widgets.entityselection', array('name' => 'unit', 'label' => _kt('Unit'), 'description' => _kt('Which Unit is this group part of?'), 'vocab' => $aUnits, 'label_method' => 'getName', 'simple_select' => false, 'unselected_label' => _kt("No unit"))), array('ktcore.widgets.boolean', array('name' => 'unitadmin', 'label' => _kt("Unit Administrators"), 'description' => _kt('Should all the members of this group be given <strong>unit</strong> administration privileges?'), 'important_description' => _kt("Note that its not possible to set a group without a unit as having unit administration privileges."), 'value' => null))));
         $oForm->addValidators(array(array('ktcore.validators.entity', array('test' => 'unit', 'class' => 'Unit', 'output' => 'unit')), array('ktcore.validators.boolean', array('test' => 'unitadmin', 'output' => 'unitadmin'))));
     }
     return $oForm;
 }