import and export
This commit is contained in:
+15
-12
@@ -15,34 +15,37 @@ class Text implements FieldInterface, RequiredInterface
|
||||
public function __construct(
|
||||
public string $name,
|
||||
public string $label,
|
||||
public bool $required = false,
|
||||
public bool $nullable = false,
|
||||
public ?int $min = null,
|
||||
public ?int $max = null,
|
||||
public bool $required = false,
|
||||
public bool $nullable = false,
|
||||
public ?int $min = null,
|
||||
public ?int $max = null,
|
||||
public string $help = "",
|
||||
public string $default = "",
|
||||
public bool $readonly = false,
|
||||
public bool $readonly = false,
|
||||
public string $optionsFrom = "",
|
||||
public string $optionsField = "",
|
||||
public bool $optionsSuggest = false,
|
||||
public bool $optionsSuggest = false,
|
||||
public ?array $selectOptions = null,
|
||||
public string $group = "",
|
||||
)
|
||||
{
|
||||
) {
|
||||
$this->info = new FieldInfo("text", "Text", FieldType::STRING);
|
||||
}
|
||||
|
||||
public function format(array $input, array $output): array
|
||||
{
|
||||
$value = !empty($input[$this->name]) ? (string)$input[$this->name] : null;
|
||||
$output[$this->name] = (new Nullable($this->nullable, $value, ""))->value();
|
||||
$value = !empty($input[$this->name])
|
||||
? (string) $input[$this->name]
|
||||
: null;
|
||||
$output[$this->name] = Nullable::make(
|
||||
$this->nullable,
|
||||
$value,
|
||||
"",
|
||||
)->value();
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
public function failRequired(mixed $value): bool
|
||||
{
|
||||
return empty(trim($value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user