ILIAS  trunk Revision v11.0_alpha-1843-g9e1fad99175
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Select.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 use ILIAS\UI\Component as C;
26 use Closure;
27 
31 class Select extends FormInput implements C\Input\Field\Select
32 {
33  protected array $options;
34  protected string $label;
35 
39  protected $value;
40 
41  public function __construct(
42  DataFactory $data_factory,
44  string $label,
45  array $options,
46  ?string $byline
47  ) {
48  parent::__construct($data_factory, $refinery, $label, $byline);
49  $this->options = $options;
50  }
51 
55  public function getOptions(): array
56  {
57  return $this->options;
58  }
59 
63  protected function isClientSideValueOk($value): bool
64  {
65  return in_array($value, array_keys($this->options)) || $value == "";
66  }
67 
71  protected function getConstraintForRequirement(): ?Constraint
72  {
73  if ($this->requirement_constraint !== null) {
75  }
76 
77  return $this->refinery->logical()->sequential([
78  $this->refinery->to()->string(),
79  $this->refinery->string()->hasMinLength(1)
80  ]);
81  }
82 
86  public function getUpdateOnLoadCode(): Closure
87  {
88  return fn($id) => "$('#$id').on('input', function(event) {
89  il.UI.input.onFieldUpdate(event, '$id', $('#$id option:selected').text());
90  });
91  il.UI.input.onFieldUpdate(event, '$id', $('#$id option:selected').text());";
92  }
93 
97  public function isComplex(): bool
98  {
99  return false;
100  }
101 }
Interface Observer Contains several chained tasks and infos about them.
A constraint encodes some resrtictions on values.
Definition: Constraint.php:31
Factory for Date Formats.
Definition: Factory.php:26
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Checkbox.php:21
__construct(DataFactory $data_factory, \ILIAS\Refinery\Factory $refinery, string $label, array $options, ?string $byline)
Definition: Select.php:41
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(Container $dic, ilPlugin $plugin)
This describes inputs that can be used in forms.
Definition: FormInput.php:32