Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Multiselect.php
Go to the documentation of this file.
1 <?php
9 
12 
13 class Multiselect extends Select
14 {
19  {
20  $values = $this->_getRequestValue($request);
21  if ($values !== false && !is_array($values)) {
22  $values = [$values];
23  }
24  return $values;
25  }
26 
30  public function compactValue($value)
31  {
32  if (is_array($value)) {
33  foreach ($value as $key => $val) {
34  $value[$key] = parent::compactValue($val);
35  }
36 
37  $value = implode(',', $value);
38  }
39  return parent::compactValue($value);
40  }
41 
46  {
48  if (!is_array($values)) {
49  $values = explode(',', $values);
50  }
51 
53  return $values;
54  }
55 
56  $output = [];
57  foreach ($values as $value) {
58  if (!$value) {
59  continue;
60  }
61  $output[] = $this->_getOptionText($value);
62  }
63 
64  $output = implode(', ', $output);
65 
66  return $output;
67  }
68 }
$values
Definition: options.phtml:88
_getRequestValue(\Magento\Framework\App\RequestInterface $request)
outputValue($format=ElementFactory::OUTPUT_FORMAT_TEXT)
Definition: Multiselect.php:45
$value
Definition: gender.phtml:16
$format
Definition: list.phtml:12