Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View values in TV listbox-multiple then it manually entered #16241

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -35,6 +35,14 @@ public function process($value,array $params = array()) {
$orderedItems = array();
// loop trough the selected values
foreach ($value as $val) {
// add custom value (from TV) if it isset
if (isset($val)) {
$orderedItems[] = array(
'text' => $val,
'value' => $val,
'selected' => 1,
);
Comment on lines +40 to +44
Copy link
Collaborator

@smg6511 smg6511 Jun 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small change to treat the custom input values the same as the pre-defined ones (htmlspecialchars). Also, I encourage the modernization of any passage of code you add or edit (here, use the short array declaration using only brackets).

Suggested change
$orderedItems[] = array(
'text' => $val,
'value' => $val,
'selected' => 1,
);
$val = htmlspecialchars($val, ENT_COMPAT, 'UTF-8');
$orderedItems[] = [
'text' => $val,
'value' => $val,
'selected' => 1
];

}
// find the corresponding option in the items array
foreach ($items as $item => $values) {
// if found, add it in the right order to the $orderItems array
Expand Down