ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
Text.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2017 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
6 
7 use ILIAS\UI\Component as C;
10 
14 class Text extends Input implements C\Input\Field\Text
15 {
19  public function __construct(
20  DataFactory $data_factory,
21  \ILIAS\Refinery\Factory $refinery,
22  $label,
23  $byline
24  ) {
25  parent::__construct($data_factory, $refinery, $label, $byline);
26  $this->setAdditionalTransformation($refinery->custom()->transformation(function ($v) {
27  return strip_tags($v);
28  }));
29  }
30 
34  protected function isClientSideValueOk($value) : bool
35  {
36  return is_string($value);
37  }
38 
39 
43  protected function getConstraintForRequirement()
44  {
45  return $this->refinery->string()->hasMinLength(1);
46  }
47 
51  public function getUpdateOnLoadCode() : \Closure
52  {
53  return function ($id) {
54  $code = "$('#$id').on('input', function(event) {
55  il.UI.input.onFieldUpdate(event, '$id', $('#$id').val());
56  });
57  il.UI.input.onFieldUpdate(event, '$id', $('#$id').val());";
58  return $code;
59  };
60  }
61 }
Class ChatMainBarProvider .
__construct(DataFactory $data_factory, \ILIAS\Refinery\Factory $refinery, $label, $byline)
Definition: Text.php:19
Builds data types.
Definition: Factory.php:19
This describes text inputs.
Definition: Text.php:10
__construct(Container $dic, ilPlugin $plugin)
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: Text.php:51