In an overridden com_users/profile layout I use the following code to get custom fields values:
I meet a problem when the custom field is a subform repeatable one.
$jcField->value gives the value of the subform, that is, a comma delimited HTML string with ul/li items of all the repeated elements that exist in the subform. Using the following code I can get only the string:
But still, the string is comma delimited and my data contain commas. I need the string exploded. but messes up the text.
Is there any other way to get each element's id, name, label, value, etc. out of a subform repeatable custom field in a similar way to the other custom fields?
Code:
$data =$this->data;$jcFields = $data->jcfields;foreach ($jcFields as $jcField) {if ($jcField->name == 'marr-date-sub') {echo $jcField->label . ': ' . $jcField->value . '<br>';}}
$jcField->value gives the value of the subform, that is, a comma delimited HTML string with ul/li items of all the repeated elements that exist in the subform. Using the following code I can get only the string:
Code:
$htmlString = $marr;$dom = new DOMDocument;$dom->loadHTML(mb_convert_encoding($htmlString, 'HTML-ENTITIES', 'UTF-8'));$xpath = new DOMXPath($dom);$liElements = $xpath->query('//li');foreach ($liElements as $liElement) {echo $liElement->nodeValue . "<br/>";}
Is there any other way to get each element's id, name, label, value, etc. out of a subform repeatable custom field in a similar way to the other custom fields?
Statistics: Posted by jathco — Thu Jan 18, 2024 7:37 am