19declare(strict_types=1);
51 string $a_postvar =
""
54 $this->
lng = $DIC->language();
58 $this->validationRegexp =
"";
66 if ($this->
getMulti() && is_array($a_value)) {
68 $a_value = array_shift($a_value);
70 $this->value = $a_value;
83 $this->validationFailureMessage = $a_msg;
93 $this->validationRegexp = $a_value;
103 $this->maxlength = $a_maxlength;
113 $this->size = $a_size;
118 $this->style_css = $a_style;
128 $this->css_class = $a_class;
148 $this->suffix = $a_value;
162 $this->input_type = $a_type;
172 $this->submit_form_on_enter = $a_val;
241 ?
string $a_delimiter =
null
243 $this->ajax_datasource = $href;
244 $this->ajax_datasource_delimiter = $a_delimiter;
249 $this->ajax_datasource_commit = $a_stat;
254 return $this->ajax_datasource_commit;
259 $this->ajax_datasource_commit_url = $a_url;
264 return $this->ajax_datasource_commit_url;
269 foreach ($a_values as $idx => $value) {
270 $a_values[$idx] = trim($value);
271 if ($a_values[$idx] ==
"") {
272 unset($a_values[$idx]);
275 parent::setMultiValues($a_values);
278 public function render(
string $a_mode =
""): string
282 $tpl =
new ilTemplate(
"tpl.prop_textinput.html",
true,
true,
"components/ILIAS/Form");
283 if (strlen((
string) $this->
getValue())) {
284 $tpl->setCurrentBlock(
"prop_text_propval");
289 $tpl->parseCurrentBlock();
291 if (strlen($this->getInlineStyle())) {
292 $tpl->setCurrentBlock(
"stylecss");
297 $tpl->parseCurrentBlock();
299 if (strlen($this->getCssClass())) {
300 $tpl->setCurrentBlock(
"classcss");
302 $tpl->parseCurrentBlock();
304 if ($this->getSubmitFormOnEnter()) {
305 $tpl->touchBlock(
"submit_form_on_enter");
308 switch ($this->getInputType()) {
310 $tpl->setVariable(
'PROP_INPUT_TYPE',
'password');
313 $tpl->setVariable(
'PROP_INPUT_TYPE',
'hidden');
317 $tpl->setVariable(
'PROP_INPUT_TYPE',
'text');
319 $tpl->setVariable(
"ID", $this->getFieldId());
320 $tpl->setVariable(
"SIZE", $this->getSize());
321 if ($this->getMaxLength() !=
null) {
322 $tpl->setVariable(
"MAXLENGTH", $this->getMaxLength());
324 if (strlen($this->getSuffix())) {
325 $tpl->setVariable(
"INPUT_SUFFIX", $this->getSuffix());
328 $postvar = $this->getPostVar();
329 if ($this->getMulti() && substr($postvar, -2) !=
"[]") {
333 $tpl->setVariable(
"POST_VAR", $postvar);
334 if ($this->getDisabled()) {
335 if ($this->getMulti()) {
336 $value = $this->getMultiValues();
338 if (is_array($value)) {
339 foreach ($value as $item) {
340 $hidden .= $this->getHiddenTag($postvar, $item);
344 $hidden = $this->getHiddenTag($postvar, $this->
getValue());
347 $tpl->setVariable(
"HIDDEN_INPUT", $hidden);
349 $tpl->setVariable(
"DISABLED",
" disabled=\"disabled\"");
353 if ($this->getDataSource()) {
354 $tpl->setVariable(
'AUTOCOMPLETE',
'autocomplete="off"');
355 $this->global_tpl->addJavaScript(
'assets/js/legacyAutocomplete.js',
true, 3);
356 $config = json_encode([
357 'delimiter' => $this->ajax_datasource_delimiter,
358 'dataSource' => $this->ajax_datasource,
359 'submitOnSelection' => $this->ajax_datasource_commit,
360 'submitUrl' => $this->ajax_datasource_commit_url,
361 'autocompleteLength' => 3,
362 'moreText' => $this->
lng->txt(
'autocomplete_more')
366 $sel_auto =
'[id^="' . $this->getFieldId() .
'"]';
369 $sel_auto =
"#" . $this->getFieldId();
372 $this->global_tpl->addOnLoadCode(
373 "il.LegacyForm.autocomplete.init(document.querySelector(`{$sel_auto}`), {$config});"
377 if ($a_mode ==
"toolbar") {
383 'display: -moz-inline-stack; display:inline-block; zoom: 1; *display:inline;'
386 $tpl->setVariable(
"STYLE_PAR",
'');
389 if ($this->isHtmlAutoCompleteDisabled()) {
390 $tpl->setVariable(
"AUTOCOMPLETE",
"autocomplete=\"off\"");
393 if ($this->getRequired()) {
394 $tpl->setVariable(
"REQUIRED",
"required=\"required\"");
398 if ($this->getMulti() && !$a_mode && !$this->getDisabled()) {
399 $tpl->touchBlock(
"inline_in_bl");
400 $tpl->setVariable(
"MULTI_ICONS", $this->getMultiIconsHTML());
404 if ($this->getInfo() !==
'') {
405 $tpl->setVariable(
'DESCRIBED_BY_FIELD_ID', $this->getFieldId());
413 $html = $this->render();
422 $html = $this->render();
428 $html = $this->render(
"toolbar");
434 $this->autocomplete_disabled = $autocomplete;
439 return $this->autocomplete_disabled;
444 return $this->getInput();
setVariable($variable, $value='')
Sets a variable value.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
This class represents a text property in a property form.
setDataSourceSubmitUrl(string $a_url)
string $ajax_datasource_commit_url
setCssClass(string $a_class)
setDisableHtmlAutoComplete(bool $autocomplete)
getTableFilterHTML()
Get input item HTML to be inserted into table filters.
getPostValueForComparison()
string $validationFailureMessage
bool $autocomplete_disabled
setInlineStyle(string $a_style)
setMultiValues(array $a_values)
setDataSourceSubmitOnSelection(bool $a_stat)
getToolbarHTML()
Get input item HTML to be inserted into ilToolbarGUI.
bool $submit_form_on_enter
insert(ilTemplate $a_tpl)
setSuffix(string $a_value)
string $ajax_datasource_delimiter
setSubmitFormOnEnter(bool $a_val)
setInputType(string $a_type)
set input type
checkInput()
Check input, strip slashes etc.
getDataSourceSubmitOnSelection()
setMaxLength(?int $a_maxlength)
setValidationRegexp(string $a_value)
getValidationFailureMessage()
__construct(string $a_title="", string $a_postvar="")
setDataSource(string $href, ?string $a_delimiter=null)
bool $ajax_datasource_commit
setValueByArray(array $a_values)
setValidationFailureMessage(string $a_msg)
isHtmlAutoCompleteDisabled()
render(string $a_mode="")
Interface for multi values support.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc