ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
FormInputNameSource.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
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:26
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...