ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
FormInputNameSource.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
30{
31 private int $count = 0;
32 private array $used_names = [];
33
37 public function getNewName(): string
38 {
39 return 'input_' . $this->count++;
40 }
41
42 public function getNewDedicatedName(string $dedicated_name): string
43 {
44 if ($dedicated_name == 'input') {
45 return $this->getNewName();
46 }
47 if (in_array($dedicated_name, $this->used_names)) {
48 return $dedicated_name . '_' . $this->count++;
49 } else {
50 $this->used_names[] = $dedicated_name;
51 return $dedicated_name;
52 }
53 }
54}
FormInputNameSource is responsible for generating continuous form input names.
Describes a source for input names.
Definition: NameSource.php:27
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...