refactor(form-builder): pre-publish check reads form_field_bindings; drop binding JSON columns

This commit is contained in:
2026-04-24 20:09:27 +02:00
parent 6933e6d700
commit 61719bf8bf
18 changed files with 375 additions and 97 deletions

View File

@@ -32,20 +32,29 @@ final class FormFieldTest extends TestCase
$this->assertIsString($field->fresh()->field_type);
}
public function test_form_field_casts_binding_and_translations_to_array(): void
public function test_form_field_casts_translations_to_array(): void
{
$field = FormField::factory()->create([
'binding' => ['mode' => 'entity_owned', 'entity' => 'person', 'column' => 'first_name'],
'translations' => ['en' => ['label' => 'First name']],
]);
$fresh = $field->fresh();
$this->assertIsArray($fresh->binding);
$this->assertSame('entity_owned', $fresh->binding['mode']);
$this->assertIsArray($fresh->translations);
$this->assertSame('First name', $fresh->translations['en']['label']);
}
public function test_form_field_bindings_relation_exposes_relational_rows(): void
{
$field = FormField::factory()
->withEntityBinding('person', 'first_name')
->create();
$binding = $field->bindings()->first();
$this->assertNotNull($binding);
$this->assertSame('person', $binding->target_entity);
$this->assertSame('first_name', $binding->target_attribute);
}
public function test_form_field_has_many_values(): void
{
$schema = FormSchema::factory()->create();