public function add__Permissions__field()
{
if (!IPF_Auth_App::ArePermissionsEnabled())
- return;
+ return null;
$choices = array();
foreach (IPF_ORM::getTable('Permission')->findAll() as $o)
$choices[$o->__toString()] = $o->id;
ksort($choices);
- $field = new IPF_Form_Field_ModelMultipleChoice(array(
+ return new IPF_Form_Field_ModelMultipleChoice(array(
'required' => false,
'label' => 'Permissions',
'help_text' => '',
'choices' => $choices,
'widget_attrs' => array('class' => 'checkgroup'),
));
-
- $this->fields['Permissions'] = $field;
}
}
{
function initFields($extra=array())
{
+ ArrayTools::pushToKey($extra, 'exclude', 'UserRole');
+ ArrayTools::pushToKey($extra, 'exclude', 'UserPermission');
parent::initFields($extra);
$this->fields['email']->label = 'E-mail';
public function add__Permissions__field()
{
if (!IPF_Auth_App::ArePermissionsEnabled())
- return;
+ return null;
$choices = array();
foreach (IPF_ORM::getTable('Permission')->findAll() as $o)
$choices[$o->__toString()] = $o->id;
ksort($choices);
- $field = new IPF_Form_Field_ModelMultipleChoice(array(
+ return new IPF_Form_Field_ModelMultipleChoice(array(
'required' => false,
'label' => 'Permissions',
'help_text' => '',
'choices' => $choices,
'widget_attrs' => array('class' => 'checkgroup'),
));
-
- $this->fields['Permissions'] = $field;
}
public function add__Roles__field()
{
if (!IPF_Auth_App::ArePermissionsEnabled())
- return;
+ return null;
$choices = array();
foreach (IPF_ORM::getTable('Role')->findAll() as $o)
$choices[$o->__toString()] = $o->id;
- $field = new IPF_Form_Field_ModelMultipleChoice(array(
+ return new IPF_Form_Field_ModelMultipleChoice(array(
'required' => false,
'label' => 'Groups',
'help_text' => 'In addition to the permissions manually assigned, this user will also get all permissions granted to each group he/she is in.',
'choices' => $choices,
'widget_attrs' => array('class' => 'checkgroup'),
));
-
- $this->fields['Roles'] = $field;
}
function isValid()
continue;
if (isset($col['exclude']) && $col['exclude'])
continue;
- $field = self::createDBField($name, $table, $col);
+
+ if ($form && method_exists($form, 'add__'.$name.'__field')) {
+ $f = call_user_func(array($form, 'add__'.$name.'__field'));
+ if ($f)
+ $field = array($name, $f);
+ } else {
+ $field = self::createDBField($name, $table, $col);
+ }
+
if ($field)
$result[] = $field;
}
continue;
if (isset($relation['exclude']) && $relation['exclude'])
continue;
- $field = self::createDBRelation($name, $relation, $db_columns);
+
+ if ($form && method_exists($form, 'add__'.$name.'__field')) {
+ $f = call_user_func(array($form, 'add__'.$name.'__field'));
+ if ($f)
+ $field = array($name, $f);
+ } else {
+ $field = self::createDBRelation($name, $relation, $db_columns);
+ }
+
if ($field)
$result[] = $field;
}
foreach ($fields as $uname) {
$field = null;
if ($form && method_exists($form, 'add__'.$uname.'__field')) {
- $field = array($uname, array($form, 'add__'.$uname.'__field'));
+ $f = call_user_func(array($form, 'add__'.$uname.'__field'));
+ if ($f)
+ $field = array($uname, $f);
} elseif (array_key_exists($uname, $db_columns)) {
$field = self::createDBField($uname, $table, $db_columns[$uname]);
} elseif (array_key_exists($uname, $db_relations)) {
else
$col = array();
- $defaults = array(
- 'blank' => !isset($col['notblank']),
- 'help_text' => '',
- 'model' => $relation->getClass(),
- 'verbose' => isset($col['verbose']) ? $col['verbose'] : $name,
- );
-
$table = IPF_ORM::getTable($relation->getClass());
$params = array(
'label' => isset($col['verbose']) ? $col['verbose'] : IPF_Utils::humanTitle($name),
'help_text' => '',
'table' => $table,
+ 'model' => $relation->getClass(),
);
if ($rt === IPF_ORM_Relation::ONE_AGGREGATE) {
$pk = $table->getIdentifier();
$choices = array();
- foreach ($table->findAll() as $o){
+ foreach ($table->findAll() as $o) {
$choices[$o->__toString()] = $o->$pk;
}