1)Create a Content Field of type List called "mylistfield" (for example) with values and activate the multiple option.
1)Create an Article and in the Fields Tab, enter two values in "mylistfield".
1)Call with the API to the created ID article {{base_url}}/{{base_path}}/content/articles/{{your article id}} with Postman
The field shows two values:
"mylistfield": [
{
"value": "Value 1",
"alias": "value-1"
},
{
"value": "Value 2",
"alias": "value-2"
},
],
"mylistfield": []
Joomla 4.2.2
Php 7.4
This code should work. I am not sure if it should be plain or associative array.
$api_values = array();
foreach ($field->rawvalue as $value) {
if (isset($options[$value])) {
//$api_values[$value => $options[$value]];
$api_values[] = array(
'value' => $options[$value],
'alias' => $value
);
}
}
$field->apivalue = $api_values;
Labels |
Added:
No Code Attached Yet
|
Title |
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-09-12 19:16:25 |
Closed_By | ⇒ | richard67 |
Closing as there is a pull request which claims to solve this issue. See #38744 .