velden wrote: ↑Sun Oct 25, 2020 7:48 am
I would pass the response object to the udt and move all logic to it too.
That's how I did it anyway.
I tried that at first but I received a message "Warning: trim() expects parameter 1 to be string, object given". Today I did found out there is a difference in using the get_parameter_value(...) , then passing an object is
not allowed
Code: Select all
$response = get_parameter_value($params,'response');
and using the $params[...] , then passing an object is allowed.
By using the $params['param_name'] all is much easier and cleaner, as you said
CGBetterForms : Validate via Smarty Template
Code: Select all
{udt_betterforms_validation response=$response}
udt name : udt_betterforms_validation
Code: Select all
$response = $params['response'];
$fields = $response->list_fields();
$arr = array();
foreach ($fields as $field) {
$arr[$field] = $response->get_field_value($field);
}
echo "<pre>"; print_r($arr); echo "</pre>";