<?php
namespace App\Form\System;
use App\Util\GenericForm;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
/**
* Used to represent Doctrine ORM Annotation Attribute
* https://www.doctrine-project.org/projects/doctrine-orm/en/current/reference/annotations-reference.html#column
* https://www.doctrine-project.org/projects/doctrine-orm/en/2.13/reference/annotations-reference.html#column
*/
class DOAAttribute extends GenericForm
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$options["fields"] = [
"type" => [
"attr" => ["class" => "form-select"],
"choices" => [
"choices.types.entity" => "entity",
"choices.types.integerTypes" => [
"choices.types.smallint" => "smallint",
"choices.types.integer" => "integer",
"choices.types.bigint" => "bigint"
],
"choices.types.decimalTypes" => [
"choices.types.decimal" => "decimal",
"choices.types.float" => "float"
],
"choices.types.stringTypes" => [
"choices.types.string" => "string",
"choices.types.text" => "text"
],
"choices.types.dateTimeTypes" => [
"choices.types.date" => "date",
"choices.types.datetime" => "datetime",
"choices.types.time" => "time"
],
],
"type" => ChoiceType::class
],
"id" => [
"attr" => ["class" => "form-check-custom"],
"type" => CheckboxType::class
],
"name" => [
"type" => TextType::class
],
"length" => [
"attr" => ["class" => "form-control", "placeholder" => "label.length"],
"html5" => true,
"type" => NumberType::class
],
"precision" => [
"attr" => ["class" => "form-control", "placeholder" => "label.precision"],
"html5" => true,
"type" => NumberType::class
],
"scale" => [
"attr" => ["class" => "form-control", "placeholder" => "label.scale"],
"html5" => true,
"type" => NumberType::class
],
"unique" => [
"attr" => ["class" => "form-control", "placeholder" => "label.unique.constraint.sort"],
"type" => TextType::class
],
"nullable" => [
"attr" => ["class" => "form-check-input"],
"type" => CheckboxType::class
],
"insertable" => [
"attr" => ["class" => "form-check-input"],
"type" => CheckboxType::class
],
"updatable" => [
"attr" => ["class" => "form-check-input"],
"type" => CheckboxType::class
],
"generated" => [
"attr" => ["class" => "form-check-input"],
"type" => CheckboxType::class
],
"options" => [
"attr" => ["class" => "container"],
"type" => DOAOptions::class
],
"columnDefinition" => [
"type" => TextType::class
],
"externalAlias" => [
"type" => TextType::class
],
"order" => [
"attr" => ["hidden" => true],
"html5" => true,
"type" => NumberType::class
]
];
foreach (array_keys($options["fields"]) as $attr) {
$options["fields"][$attr]["label"] = false;
$options["fields"][$attr]["required"] = $attr == "type";
}
parent::buildForm($builder, $options);
}
}