2023-12-26 00:44:49 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Form\Fields;
|
|
|
|
|
2024-02-16 14:18:16 +01:00
|
|
|
use App\Form\Models\Form;
|
|
|
|
use App\Form\Models\Participant;
|
2023-12-26 20:06:57 +01:00
|
|
|
use Faker\Generator;
|
|
|
|
|
2023-12-26 00:44:49 +01:00
|
|
|
class TextareaField extends Field
|
|
|
|
{
|
2024-02-06 01:45:25 +01:00
|
|
|
public bool $required;
|
2024-03-07 00:58:14 +01:00
|
|
|
public int $rows;
|
2024-02-06 01:45:25 +01:00
|
|
|
|
2023-12-26 00:44:49 +01:00
|
|
|
public static function name(): string
|
|
|
|
{
|
|
|
|
return 'Textarea';
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function meta(): array
|
|
|
|
{
|
|
|
|
return [
|
2023-12-26 20:06:57 +01:00
|
|
|
['key' => 'rows', 'default' => 5, 'rules' => ['rows' => 'present|integer|gt:0'], 'label' => 'Zeilen'],
|
2024-04-12 15:23:18 +02:00
|
|
|
['key' => 'required', 'default' => true, 'rules' => ['required' => 'present|boolean'], 'label' => 'Erforderlich'],
|
2023-12-26 00:44:49 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function default(): string
|
|
|
|
{
|
|
|
|
return '';
|
|
|
|
}
|
2023-12-26 20:06:57 +01:00
|
|
|
|
|
|
|
public static function fake(Generator $faker): array
|
|
|
|
{
|
2023-12-27 22:39:23 +01:00
|
|
|
return [
|
|
|
|
'rows' => $faker->numberBetween(5, 10),
|
|
|
|
'required' => $faker->boolean(),
|
|
|
|
];
|
2023-12-26 20:06:57 +01:00
|
|
|
}
|
2024-02-06 01:45:25 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2024-02-19 02:10:58 +01:00
|
|
|
public function getRegistrationRules(Form $form): array
|
2024-02-06 01:45:25 +01:00
|
|
|
{
|
|
|
|
return [$this->key => $this->required ? ['required', 'string'] : ['nullable', 'string']];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2024-02-19 02:10:58 +01:00
|
|
|
public function getRegistrationAttributes(Form $form): array
|
2024-02-06 01:45:25 +01:00
|
|
|
{
|
|
|
|
return [$this->key => $this->name];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2024-02-19 02:10:58 +01:00
|
|
|
public function getRegistrationMessages(Form $form): array
|
2024-02-06 01:45:25 +01:00
|
|
|
{
|
|
|
|
return [];
|
|
|
|
}
|
2024-02-16 14:18:16 +01:00
|
|
|
|
2024-02-16 14:32:16 +01:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2024-02-16 14:18:16 +01:00
|
|
|
public function afterRegistration(Form $form, Participant $participant, array $input): void
|
|
|
|
{
|
|
|
|
}
|
2023-12-26 00:44:49 +01:00
|
|
|
}
|