From ae73511958254a8c78d5e8cd3d2e439b2a92a689 Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 2 May 2022 17:06:33 -0600 Subject: [PATCH] Make sure customfields get their set_row_value() method called. Fixes customfield dates were not sent in correct format --- api/src/Etemplate/Widget/Customfields.php | 32 ++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/api/src/Etemplate/Widget/Customfields.php b/api/src/Etemplate/Widget/Customfields.php index 51c975e7a0..45ca5d0aa7 100644 --- a/api/src/Etemplate/Widget/Customfields.php +++ b/api/src/Etemplate/Widget/Customfields.php @@ -369,13 +369,43 @@ class Customfields extends Transformer if (is_array($options)) { Select::fix_encoded_options($options); - self::$request->sel_options[self::$prefix.$fname] = $options; + self::$request->sel_options[self::$prefix . $fname] = $options; } break; } return $widget; } + /** + * Perform any needed data manipulation on each row + * before sending it to client. + * + * This is used by Nextmatch on each row to do any needed + * adjustments. Used here to make sure sub-widgets get their set_row_value method called + * + * @param string $cname + * @param array $expand + * @param array $data Row data + */ + public function set_row_value($cname, array $expand, array &$data) + { + $form_name = self::form_name($cname, $this->id, $expand); + $value =& $this->get_array($data, $form_name, true); + $customfields = Api\Storage\Customfields::get($this->attrs['app']); + + foreach($customfields as $field_name => $field) + { + if(array_key_exists(self::$prefix . $field_name, $value)) + { + $widget = $this->_widget($field_name, $field); + if(method_exists($widget, 'set_row_value')) + { + $widget->set_row_value('', $expand, $data[$form_name]); + } + } + } + } + /** * Validate input *