Commit bcb37212 authored by jesschampion's avatar jesschampion

Merge branch 'SNZ-329' into 'master'

SNZ-329 FIX: section display rules on nested fields

See merge request !44
parents 0f1b2a39 97dde065
......@@ -190,4 +190,26 @@ class EditableFormFieldExtension extends DataExtension implements UserSurveysFor
return null;
}
/**
* @return string - name of this field, prefixed by parent names using dot notation
*/
public function getKey() {
if ($this->owner instanceof EditableFormField) {
$prefix = '';
$parent = $this->owner->getParent();
if ($parent && $parent instanceof EditableFormField) {
$parentKey = $parent->getKey();
if ($parentKey) {
$prefix = $parentKey . '.';
}
}
return $prefix . $this->owner->Name;
} else if ($this->owner instanceof Section) {
return '';
}
}
}
......@@ -41,7 +41,7 @@ class UserSurveysDisplayRule extends DataObject implements UserSurveysJsonSerial
public function getFieldDefinition()
{
$definition = [
'name' => $this->getName(),
'name' => $this->Field() ? $this->Field()->getKey() : '',
'values' => $this->Values,
];
......@@ -55,11 +55,6 @@ class UserSurveysDisplayRule extends DataObject implements UserSurveysJsonSerial
return $definition;
}
public function getName()
{
return $this->Field() ? $this->Field()->Name : '';
}
/**
* @return array - array of field name => title
*/
......
Markdown is supported
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