ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
29 public function __construct(
30 DataFactory $data_factory,
31 \ILIAS\Refinery\Factory $refinery,
32 $label,
33 $options,
34 $byline
35 ) {
36 parent::__construct($data_factory, $refinery, $label, $byline);
37 $this->options = $options;
38 }
39
43 public function getOptions()
44 {
45 return $this->options;
46 }
47
51 protected function isClientSideValueOk($value) : bool
52 {
53 return
54 in_array($value, array_keys($this->options))
55 || $value == "";
56 }
57
61 protected function getConstraintForRequirement()
62 {
63 return $this->refinery->string()->hasMinLength(1);
64 }
65
69 public function getUpdateOnLoadCode() : \Closure
70 {
71 return function ($id) {
72 $code = "$('#$id').on('input', function(event) {
73 il.UI.input.onFieldUpdate(event, '$id', $('#$id option:selected').text());
74 });
75 il.UI.input.onFieldUpdate(event, '$id', $('#$id option:selected').text());";
76 return $code;
77 };
78 }
79}
An exception for terminatinating execution or to throw for unit testing.
Builds data types.
Definition: Factory.php:20
getUpdateOnLoadCode()
Get update code.This method has to return JS code that calls il.UI.filter.onFieldUpdate(event,...
Definition: Select.php:69
__construct(DataFactory $data_factory, \ILIAS\Refinery\Factory $refinery, $label, $options, $byline)
Select constructor.
Definition: Select.php:29
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.