Commit 0f255bb9 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:sparkles: feat(template) Add a method to alter template attributes

This method allows to set some attributes as mandatory, readonly or
 hidden.
It may be done in an other way later but this will allow to start
 testing it in public-forms plugin

issue #5854
Showing with 29 additions and 0 deletions
+29 -0
...@@ -142,6 +142,35 @@ class template ...@@ -142,6 +142,35 @@ class template
return $this->attributes; return $this->attributes;
} }
function alterAttributes($mandatories, $readonly, $hidden)
{
foreach ($mandatories as $class => $attrs) {
foreach ($attrs as $attr) {
if (!in_array($attr, $this->attributes[$class])) {
$this->attributes[$class][] = $attr;
}
$this->tabObject->by_object[$class]->attributesAccess[$attr]->setRequired(TRUE);
}
}
foreach ($readonly as $class => $attrs) {
foreach ($attrs as $attr) {
if (!in_array($attr, $this->attributes[$class])) {
$this->attributes[$class][] = $attr;
}
$this->tabObject->by_object[$class]->attributesAccess[$attr]->setDisabled(TRUE);
}
}
foreach ($hidden as $class => $attrs) {
foreach ($attrs as $attr) {
if (!in_array($attr, $this->attributes[$class])) {
$this->attributes[$class][] = $attr;
}
$this->tabObject->by_object[$class]->attributesAccess[$attr]->setDisabled(TRUE);
$this->tabObject->by_object[$class]->attributesAccess[$attr]->setVisible(FALSE);
}
}
}
function serialize() function serialize()
{ {
$ret = array(); $ret = array();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment