MultiSelect.php 877 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Ui\Component\Form\Element;
  7. /**
  8. * @api
  9. * @since 100.0.2
  10. */
  11. class MultiSelect extends AbstractOptionsField
  12. {
  13. const NAME = 'multiselect';
  14. const DEFAULT_SIZE = 6;
  15. /**
  16. * {@inheritdoc}
  17. */
  18. public function prepare()
  19. {
  20. $config['size'] = self::DEFAULT_SIZE;
  21. $this->setData('config', array_replace_recursive((array)$this->getData('config'), $config));
  22. parent::prepare();
  23. }
  24. /**
  25. * {@inheritdoc}
  26. * @since 100.1.0
  27. */
  28. public function getComponentName()
  29. {
  30. return static::NAME;
  31. }
  32. /**
  33. * {@inheritdoc}
  34. * @since 100.1.0
  35. */
  36. public function getIsSelected($optionValue)
  37. {
  38. return in_array($optionValue, (array) $this->getValue());
  39. }
  40. }