/** * Custom options mapping * * @param array|null $fields * @param string|null $parent * @return array * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function dataMapping(array $fields = null, $parent = null) { list($option, $type, $title, $titleOption) = $fields; $isDate = $type == 'Date' || $type == 'Time' || $type == 'Date & Time'; $isChecked = $type == 'Checkbox' || $type == 'Radio Buttons'; $isField = $type == 'Field' || $type == 'Area'; $optionName = strtolower(preg_replace('/[^a-zA-Z]/', '', $type)); $option += parent::dataMapping([$optionName => []]); $selector = [$option[$optionName]['selector']]; if ($isDate) { $value = explode('/', $option['value'][0]); $selector = $this->setDateTypeSelector(count($value), $selector[0]); } elseif ($isChecked) { $selector[0] = str_replace('%option_name%', $titleOption[0], $selector[0]); $value = ['Yes']; } elseif ($isField) { $value = $option['value']; } else { $value = $titleOption; } return ['title' => $title, 'value' => $value, 'selector' => $selector, 'input' => $option[$optionName]['input']]; }