ILIAS  release_8 Revision v8.24
Select.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\Data\Factory as DataFactory;
26use Closure;
27
31class Select extends FormInput implements C\Input\Field\Select
32{
33 protected array $options;
34 protected string $label;
35
39 protected $value;
40 private bool $complex = false;
41
42 public function __construct(
43 DataFactory $data_factory,
44 \ILIAS\Refinery\Factory $refinery,
45 string $label,
46 array $options,
47 ?string $byline
48 ) {
49 parent::__construct($data_factory, $refinery, $label, $byline);
50 $this->options = $options;
51 }
52
56 public function getOptions(): array
57 {
58 return $this->options;
59 }
60
64 protected function isClientSideValueOk($value): bool
65 {
66 return in_array($value, array_keys($this->options)) || $value == "";
67 }
68
73 {
74 if ($this->requirement_constraint !== null) {
75 return $this->requirement_constraint;
76 }
77
78 return $this->refinery->logical()->sequential([
79 $this->refinery->to()->string(),
80 $this->refinery->string()->hasMinLength(1)
81 ]);
82 }
83
87 public function getUpdateOnLoadCode(): Closure
88 {
89 return fn ($id) => "$('#$id').on('input', function(event) {
90 il.UI.input.onFieldUpdate(event, '$id', $('#$id option:selected').text());
91 });
92 il.UI.input.onFieldUpdate(event, '$id', $('#$id option:selected').text());";
93 }
94
98 public function isComplex(): bool
99 {
100 return $this->complex;
101 }
102}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Factory for Date Formats.
Definition: Factory.php:27
Builds data types.
Definition: Factory.php:21
__construct(DataFactory $data_factory, \ILIAS\Refinery\Factory $refinery, string $label, array $options, ?string $byline)
Definition: Select.php:42
getUpdateOnLoadCode()
Get update code.This method has to return JS code that calls il.UI.filter.onFieldUpdate(event,...
Definition: Select.php:87
A constraint encodes some resrtictions on values.
Definition: Constraint.php:32
This describes inputs that can be used in forms.
Definition: FormInput.php:32
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Refinery Factory $refinery
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Checkbox.php:21
Class ChatMainBarProvider \MainMenu\Provider.