Skip to content
Snippets Groups Projects
Commit 9c75ef60 authored by Jared Hancock's avatar Jared Hancock
Browse files

forms: Any field can have sub fields

Not just the SelectionField. This will make room for the InlineFormField
parent 3770653f
No related branches found
No related tags found
No related merge requests found
...@@ -249,8 +249,8 @@ Filter::addSupportedMatches(/* @trans */ 'User Data', function() { ...@@ -249,8 +249,8 @@ Filter::addSupportedMatches(/* @trans */ 'User Data', function() {
if (!$f->hasData()) if (!$f->hasData())
continue; continue;
$matches['field.'.$f->get('id')] = __('User').' / '.$f->getLabel(); $matches['field.'.$f->get('id')] = __('User').' / '.$f->getLabel();
if (($fi = $f->getImpl()) instanceof SelectionField) { if (($fi = $f->getImpl()) && $fi->hasSubFields()) {
foreach ($fi->getList()->getForm()->getFields() as $p) { foreach ($fi->getSubFields() as $p) {
$matches['field.'.$f->get('id').'.'.$p->get('id')] $matches['field.'.$f->get('id').'.'.$p->get('id')]
= __('User').' / '.$f->getLabel().' / '.$p->getLabel(); = __('User').' / '.$f->getLabel().' / '.$p->getLabel();
} }
...@@ -339,8 +339,8 @@ Filter::addSupportedMatches(/* @trans */ 'Ticket Data', function() { ...@@ -339,8 +339,8 @@ Filter::addSupportedMatches(/* @trans */ 'Ticket Data', function() {
if (!$f->hasData()) if (!$f->hasData())
continue; continue;
$matches['field.'.$f->get('id')] = __('Ticket').' / '.$f->getLabel(); $matches['field.'.$f->get('id')] = __('Ticket').' / '.$f->getLabel();
if (($fi = $f->getImpl()) instanceof SelectionField) { if (($fi = $f->getImpl()) && $fi->hasSubFields()) {
foreach ($fi->getList()->getForm()->getFields() as $p) { foreach ($fi->getSubFields() as $p) {
$matches['field.'.$f->get('id').'.'.$p->get('id')] $matches['field.'.$f->get('id').'.'.$p->get('id')]
= __('Ticket').' / '.$f->getLabel().' / '.$p->getLabel(); = __('Ticket').' / '.$f->getLabel().' / '.$p->getLabel();
} }
...@@ -381,8 +381,8 @@ Filter::addSupportedMatches(/* trans */ 'Custom Forms', function() { ...@@ -381,8 +381,8 @@ Filter::addSupportedMatches(/* trans */ 'Custom Forms', function() {
if (!$f->hasData()) if (!$f->hasData())
continue; continue;
$matches['field.'.$f->get('id')] = $form->getTitle().' / '.$f->getLabel(); $matches['field.'.$f->get('id')] = $form->getTitle().' / '.$f->getLabel();
if (($fi = $f->getImpl()) instanceof SelectionField) { if (($fi = $f->getImpl()) && $fi->hasSubFields()) {
foreach ($fi->getList()->getProperties() as $p) { foreach ($fi->getSubFields() as $p) {
$matches['field.'.$f->get('id').'.'.$p->get('id')] $matches['field.'.$f->get('id').'.'.$p->get('id')]
= $form->getTitle().' / '.$f->getLabel().' / '.$p->getLabel(); = $form->getTitle().' / '.$f->getLabel().' / '.$p->getLabel();
} }
...@@ -1030,6 +1030,13 @@ class SelectionField extends FormField { ...@@ -1030,6 +1030,13 @@ class SelectionField extends FormField {
return true; return true;
} }
function hasSubFields() {
return true;
}
function getSubFields() {
return $this->getConfigurationForm()->getFields();
}
function toString($items) { function toString($items) {
return ($items && is_array($items)) return ($items && is_array($items))
? implode(', ', $items) : (string) $items; ? implode(', ', $items) : (string) $items;
......
...@@ -538,6 +538,18 @@ class FormField { ...@@ -538,6 +538,18 @@ class FormField {
return false; return false;
} }
/**
* Indicates if the field has subfields accessible via getSubFields()
* method. Useful for filter integration. Should connect with
* getFilterData()
*/
function hasSubFields() {
return false;
}
function getSubFields() {
return null;
}
function getConfigurationForm($source=null) { function getConfigurationForm($source=null) {
if (!$this->_cform) { if (!$this->_cform) {
$type = static::getFieldType($this->get('type')); $type = static::getFieldType($this->get('type'));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment