ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
8 use ILIAS\UI\Component as C;
10 
14 class 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 }
Class ChatMainBarProvider .
This describes select field.
Definition: Select.php:10
__construct(DataFactory $data_factory, \ILIAS\Refinery\Factory $refinery, $label, $options, $byline)
Select constructor.
Definition: Select.php:29
getUpdateOnLoadCode()
Get update code.This method has to return JS code that calls il.UI.filter.onFieldUpdate(event, &#39;$id&#39;, string_value);initially "onload" andon every input change. It must pass a readable string representation of its value in parameter &#39;string_value&#39;.string
Definition: Select.php:69
Builds data types.
Definition: Factory.php:19
__construct(Container $dic, ilPlugin $plugin)