diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index 4fd745e8c700a6909dc4de30d3b37359c889b1bf..1add7ca244e2b2d4d6a844cc7f9264dc51df53ec 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -249,8 +249,8 @@ Filter::addSupportedMatches(/* @trans */ 'User Data', function() { if (!$f->hasData()) continue; $matches['field.'.$f->get('id')] = __('User').' / '.$f->getLabel(); - if (($fi = $f->getImpl()) instanceof SelectionField) { - foreach ($fi->getList()->getForm()->getFields() as $p) { + if (($fi = $f->getImpl()) && $fi->hasSubFields()) { + foreach ($fi->getSubFields() as $p) { $matches['field.'.$f->get('id').'.'.$p->get('id')] = __('User').' / '.$f->getLabel().' / '.$p->getLabel(); } @@ -339,8 +339,8 @@ Filter::addSupportedMatches(/* @trans */ 'Ticket Data', function() { if (!$f->hasData()) continue; $matches['field.'.$f->get('id')] = __('Ticket').' / '.$f->getLabel(); - if (($fi = $f->getImpl()) instanceof SelectionField) { - foreach ($fi->getList()->getForm()->getFields() as $p) { + if (($fi = $f->getImpl()) && $fi->hasSubFields()) { + foreach ($fi->getSubFields() as $p) { $matches['field.'.$f->get('id').'.'.$p->get('id')] = __('Ticket').' / '.$f->getLabel().' / '.$p->getLabel(); } @@ -381,8 +381,8 @@ Filter::addSupportedMatches(/* trans */ 'Custom Forms', function() { if (!$f->hasData()) continue; $matches['field.'.$f->get('id')] = $form->getTitle().' / '.$f->getLabel(); - if (($fi = $f->getImpl()) instanceof SelectionField) { - foreach ($fi->getList()->getProperties() as $p) { + if (($fi = $f->getImpl()) && $fi->hasSubFields()) { + foreach ($fi->getSubFields() as $p) { $matches['field.'.$f->get('id').'.'.$p->get('id')] = $form->getTitle().' / '.$f->getLabel().' / '.$p->getLabel(); } @@ -1030,6 +1030,13 @@ class SelectionField extends FormField { return true; } + function hasSubFields() { + return true; + } + function getSubFields() { + return $this->getConfigurationForm()->getFields(); + } + function toString($items) { return ($items && is_array($items)) ? implode(', ', $items) : (string) $items; diff --git a/include/class.forms.php b/include/class.forms.php index d8c93f2c769accb26d38bbcb1d95f4f6731e74da..3b55aa353421b462ab4d1c3b49d15ddf1e3365c8 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -538,6 +538,18 @@ class FormField { 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) { if (!$this->_cform) { $type = static::getFieldType($this->get('type'));