ILIAS  release_7 Revision v7.30-3-g800a261c036
Select.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2017 Jesús López <lopez@leifos.com> Extended GPL, see docs/LICENSE */
4
6
7use ILIAS\Data\Factory as DataFactory;
10
14class Select extends Input implements C\Input\Field\Select
15{
16 protected $options;
17 protected $label;
18 protected $value;
19
23 private $complex = false;
24
34 public function __construct(
35 DataFactory $data_factory,
36 \ILIAS\Refinery\Factory $refinery,
37 $label,
38 $options,
39 $byline
40 ) {
41 parent::__construct($data_factory, $refinery, $label, $byline);
42 $this->options = $options;
43 }
44
48 public function getOptions()
49 {
50 return $this->options;
51 }
52
56 protected function isClientSideValueOk($value) : bool
57 {
58 return
59 in_array($value, array_keys($this->options))
60 || $value == "";
61 }
62
66 protected function getConstraintForRequirement()
67 {
68 return $this->refinery->string()->hasMinLength(1);
69 }
70
74 public function getUpdateOnLoadCode() : \Closure
75 {
76 return function ($id) {
77 $code = "$('#$id').on('input', function(event) {
78 il.UI.input.onFieldUpdate(event, '$id', $('#$id option:selected').text());
79 });
80 il.UI.input.onFieldUpdate(event, '$id', $('#$id option:selected').text());";
81 return $code;
82 };
83 }
84
88 public function isComplex() : bool
89 {
90 return $this->complex;
91 }
92}
An exception for terminatinating execution or to throw for unit testing.
Builds data types.
Definition: Factory.php:20
__construct(DataFactory $data_factory, \ILIAS\Refinery\Factory $refinery, $label, $options, $byline)
Select constructor.
Definition: Select.php:34
This describes commonalities between all inputs.
Definition: Input.php:32
This describes select field.
Definition: Select.php:11
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Class ChatMainBarProvider \MainMenu\Provider.