Use Joomla password field for AI key

This commit is contained in:
Wojtek
2026-10-16 12:28:50 +02:00
parent bb1dc728d1
commit 3efb937469
5 changed files with 8 additions and 9 deletions
@@ -4,24 +4,22 @@ namespace Komponent\Component\Testquestions\Administrator\Field;
defined('_JEXEC') or die;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\Form\Field\PasswordField;
class AiapikeyField extends FormField
class AiapikeyField extends PasswordField
{
protected $type = 'Aiapikey';
protected function getInput(): string
{
$id = htmlspecialchars($this->id, ENT_QUOTES, 'UTF-8');
$name = htmlspecialchars($this->name, ENT_QUOTES, 'UTF-8');
$value = htmlspecialchars((string) $this->value, ENT_QUOTES, 'UTF-8');
$length = mb_strlen((string) $this->value);
return '<div class="input-group">'
. '<input type="password" id="' . $id . '" name="' . $name . '" value="' . $value . '" size="120" autocomplete="off" class="form-control">'
. parent::getInput()
. '<button type="button" class="btn btn-outline-secondary" data-ai-key-toggle="' . $id . '">Pokaż</button>'
. '</div>'
. '<small class="form-text text-muted">Zapisany klucz: ' . (int) $length . ' znaków.</small>'
. '<small class="form-text text-muted">Klucz: ' . (int) $length . ' znaków.</small>'
. '<script>
document.addEventListener("click", function (event) {
var button = event.target.closest("[data-ai-key-toggle]");