Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 2569

Joomla! 4.x Coding • How to get subform repeatable values?

$
0
0
In an overridden com_users/profile layout I use the following code to get custom fields values:

Code:

$data =$this->data;$jcFields = $data->jcfields;foreach ($jcFields as $jcField) {if ($jcField->name == 'marr-date-sub') {echo $jcField->label . ': ' . $jcField->value . '<br>';}}
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:

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/>";}
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?

Statistics: Posted by jathco — Thu Jan 18, 2024 7:37 am



Viewing all articles
Browse latest Browse all 2569

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>