sveltel fixes

This commit is contained in:
2023-10-06 18:47:50 +03:00
parent 9bbe5ee9b4
commit 0eaf410090
28 changed files with 361 additions and 218 deletions
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace Lucent\Schema\Ui;
use Illuminate\Support\Str;
use Lucent\Schema\FieldInfo;
use Lucent\Schema\FieldInterface;
use Lucent\Schema\FieldType;
use Lucent\Schema\Nullable;
use Lucent\Schema\Validator\RequiredInterface;
class Slug implements FieldInterface, RequiredInterface
{
public FieldInfo $info;
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 string $default = "",
public bool $readonly = false,
public string $source = "",
public string $group = "",
)
{
$this->info = new FieldInfo("slug", "Slug", FieldType::STRING);
}
public function format(array $input, array $output): array
{
$value = $input[$this->name] ?? null;
if(empty($value)){
$value = Str::slug($input[$this->source]);
}
$output[$this->name] = (new Nullable($this->nullable, $value, ""))->value();
return $output;
}
public function failRequired(mixed $value): bool
{
return empty(trim($value));
}
}
+1
View File
@@ -24,6 +24,7 @@ class Text implements FieldInterface, RequiredInterface
public string $optionsFrom = "",
public string $optionsField = "",
public bool $optionsSuggest = false,
public ?array $selectOptions = null,
public string $group = "",
)
{