refactor fields

This commit is contained in:
2024-03-21 22:33:41 +02:00
parent bb77a37ff7
commit 8526fd471f
68 changed files with 635 additions and 297 deletions
+9 -9
View File
@@ -5,14 +5,15 @@ namespace Lucent\Schema\Ui;
use Lucent\JsonSchema\Property\Property;
use Lucent\JsonSchema\Property\PropertyType;
use Lucent\JsonSchema\Property\TypeProperty;
use Lucent\Schema\FieldInfo;
use Lucent\Schema\FieldInterface;
use Lucent\Schema\FieldType;
use Lucent\Schema\Nullable;
use Lucent\Record\RecordData;
use Lucent\Schema\Field\FieldDataInterface;
use Lucent\Schema\Field\FieldInfo;
use Lucent\Schema\Field\FieldInterface;
use Lucent\Schema\Field\FieldType;
use Lucent\Schema\Validator\RequiredInterface;
use PhpOption\Option;
class Text implements FieldInterface, RequiredInterface
class Text implements FieldInterface,FieldDataInterface, RequiredInterface
{
public FieldInfo $info;
@@ -20,7 +21,6 @@ class Text implements FieldInterface, RequiredInterface
public string $name,
public string $label,
public bool $required = false,
public bool $nullable = false,
public ?int $min = null,
public ?int $max = null,
public string $help = "",
@@ -36,10 +36,10 @@ class Text implements FieldInterface, RequiredInterface
$this->info = new FieldInfo("text", "Text", FieldType::STRING);
}
public function format(array $input, array $output): array
public function format(RecordData $input, RecordData $output): RecordData
{
$value = !empty($input[$this->name]) ? (string)$input[$this->name] : null;
$output[$this->name] = (new Nullable($this->nullable, $value, ""))->value();
$value = $input->get($this->name);
$output->set($this->name,$value);
return $output;
}