ILIAS  release_7 Revision v7.30-3-g800a261c036
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
8use ILIAS\Data\Factory as DataFactory;
10
14class Text extends Input implements C\Input\Field\Text
15{
19 private $complex = false;
20
24 public function __construct(
25 DataFactory $data_factory,
26 \ILIAS\Refinery\Factory $refinery,
27 $label,
28 $byline
29 ) {
30 parent::__construct($data_factory, $refinery, $label, $byline);
31 $this->setAdditionalTransformation($refinery->custom()->transformation(function ($v) {
32 return strip_tags($v);
33 }));
34 }
35
39 protected function isClientSideValueOk($value) : bool
40 {
41 return is_string($value);
42 }
43
44
48 protected function getConstraintForRequirement()
49 {
50 return $this->refinery->string()->hasMinLength(1);
51 }
52
56 public function getUpdateOnLoadCode() : \Closure
57 {
58 return function ($id) {
59 $code = "$('#$id').on('input', function(event) {
60 il.UI.input.onFieldUpdate(event, '$id', $('#$id').val());
61 });
62 il.UI.input.onFieldUpdate(event, '$id', $('#$id').val());";
63 return $code;
64 };
65 }
66
70 public function isComplex() : bool
71 {
72 return $this->complex;
73 }
74}
An exception for terminatinating execution or to throw for unit testing.
Builds data types.
Definition: Factory.php:20
__construct(DataFactory $data_factory, \ILIAS\Refinery\Factory $refinery, $label, $byline)
Definition: Text.php:24
This describes commonalities between all inputs.
Definition: Input.php:32
This describes text inputs.
Definition: Text.php:11
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Class ChatMainBarProvider \MainMenu\Provider.