242 lines
7.4 KiB
JSON
242 lines
7.4 KiB
JSON
{
|
|
"class": "App\\Form\\ProductType",
|
|
"fields": [
|
|
{
|
|
"name": "name",
|
|
"type": "Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType",
|
|
"options": {
|
|
"label": "Name",
|
|
"help": "As shown in the shop",
|
|
"attr": {
|
|
"placeholder": "A lamp",
|
|
"class": "wide"
|
|
},
|
|
"row_attr": {
|
|
"class": "row-name"
|
|
},
|
|
"constraints": [
|
|
{
|
|
"@new": "Symfony\\Component\\Validator\\Constraints\\NotBlank",
|
|
"args": []
|
|
},
|
|
{
|
|
"@new": "Symfony\\Component\\Validator\\Constraints\\Length",
|
|
"args": {
|
|
"min": 3,
|
|
"max": 80
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"name": "description",
|
|
"type": "Symfony\\Component\\Form\\Extension\\Core\\Type\\TextareaType",
|
|
"options": {
|
|
"required": false,
|
|
"empty_data": ""
|
|
}
|
|
},
|
|
{
|
|
"name": "contactEmail",
|
|
"type": "Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType",
|
|
"options": {
|
|
"constraints": [
|
|
{
|
|
"@new": "Symfony\\Component\\Validator\\Constraints\\Email",
|
|
"args": {
|
|
"message": "Not an e-mail."
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"name": "stock",
|
|
"type": "Symfony\\Component\\Form\\Extension\\Core\\Type\\IntegerType",
|
|
"options": {
|
|
"constraints": [
|
|
{
|
|
"@new": "Symfony\\Component\\Validator\\Constraints\\PositiveOrZero",
|
|
"args": []
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"name": "weight",
|
|
"type": "Symfony\\Component\\Form\\Extension\\Core\\Type\\NumberType",
|
|
"options": {
|
|
"scale": 2,
|
|
"html5": true
|
|
}
|
|
},
|
|
{
|
|
"name": "price",
|
|
"type": "Symfony\\Component\\Form\\Extension\\Core\\Type\\MoneyType",
|
|
"options": {
|
|
"currency": "EUR",
|
|
"divisor": 100
|
|
}
|
|
},
|
|
{
|
|
"name": "size",
|
|
"type": "Symfony\\Component\\Form\\Extension\\Core\\Type\\ChoiceType",
|
|
"options": {
|
|
"choices": {
|
|
"Small": "s",
|
|
"Medium": "m",
|
|
"Large": "l"
|
|
},
|
|
"expanded": true,
|
|
"multiple": false
|
|
}
|
|
},
|
|
{
|
|
"name": "status",
|
|
"type": "Symfony\\Component\\Form\\Extension\\Core\\Type\\EnumType",
|
|
"options": {
|
|
"class": {
|
|
"@class": "App\\Enum\\Status"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "category",
|
|
"type": "Symfony\\Bridge\\Doctrine\\Form\\Type\\EntityType",
|
|
"options": {
|
|
"class": {
|
|
"@class": "App\\Entity\\Category"
|
|
},
|
|
"choice_label": "title",
|
|
"query_builder": {
|
|
"@php": "fn (EntityRepository $er) => $er->createQueryBuilder('c')->orderBy('c.title', 'ASC')",
|
|
"@uses": [
|
|
"Doctrine\\ORM\\EntityRepository"
|
|
]
|
|
},
|
|
"placeholder": "Choose a category"
|
|
}
|
|
},
|
|
{
|
|
"name": "images",
|
|
"type": "Symfony\\Component\\Form\\Extension\\Core\\Type\\CollectionType",
|
|
"options": {
|
|
"entry_type": {
|
|
"@class": "Symfony\\Component\\Form\\Extension\\Core\\Type\\UrlType"
|
|
},
|
|
"entry_options": {
|
|
"label": false
|
|
},
|
|
"allow_add": true,
|
|
"allow_delete": true,
|
|
"by_reference": false,
|
|
"prototype": true
|
|
}
|
|
},
|
|
{
|
|
"name": "manual",
|
|
"type": "Symfony\\Component\\Form\\Extension\\Core\\Type\\FileType",
|
|
"options": {
|
|
"mapped": false,
|
|
"required": false,
|
|
"constraints": [
|
|
{
|
|
"@new": "Symfony\\Component\\Validator\\Constraints\\File",
|
|
"args": {
|
|
"maxSize": "2M",
|
|
"mimeTypes": [
|
|
"application/pdf"
|
|
]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"name": "releasedAt",
|
|
"type": "Symfony\\Component\\Form\\Extension\\Core\\Type\\DateType",
|
|
"options": {
|
|
"widget": "single_text",
|
|
"input": "datetime_immutable"
|
|
}
|
|
},
|
|
{
|
|
"name": "availableFrom",
|
|
"type": "Symfony\\Component\\Form\\Extension\\Core\\Type\\DateTimeType",
|
|
"options": {
|
|
"widget": "single_text",
|
|
"html5": false
|
|
}
|
|
},
|
|
{
|
|
"name": "published",
|
|
"type": "Symfony\\Component\\Form\\Extension\\Core\\Type\\CheckboxType",
|
|
"options": {
|
|
"required": false
|
|
}
|
|
},
|
|
{
|
|
"name": "secret",
|
|
"type": "Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType",
|
|
"options": {
|
|
"type": {
|
|
"@class": "Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType"
|
|
},
|
|
"invalid_message": "The two values differ.",
|
|
"first_options": {
|
|
"label": "Secret"
|
|
},
|
|
"second_options": {
|
|
"label": "Repeat it"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "address",
|
|
"type": "App\\Form\\AddressType",
|
|
"options": []
|
|
},
|
|
{
|
|
"name": "token",
|
|
"type": "Symfony\\Component\\Form\\Extension\\Core\\Type\\HiddenType",
|
|
"options": {
|
|
"mapped": false
|
|
}
|
|
},
|
|
{
|
|
"name": "save",
|
|
"type": "Symfony\\Component\\Form\\Extension\\Core\\Type\\SubmitType",
|
|
"options": {
|
|
"label": "Save the product"
|
|
}
|
|
}
|
|
],
|
|
"events": [
|
|
{
|
|
"event": "PRE_SET_DATA",
|
|
"method": "onPreSetData"
|
|
},
|
|
{
|
|
"event": "POST_SUBMIT",
|
|
"method": "onPostSubmit"
|
|
}
|
|
],
|
|
"transformers": [
|
|
{
|
|
"field": "name",
|
|
"kind": "model",
|
|
"class": "App\\Form\\DataTransformer\\TrimTransformer"
|
|
}
|
|
],
|
|
"defaults": {
|
|
"data_class": {
|
|
"@class": "App\\Entity\\Product"
|
|
},
|
|
"validation_groups": [
|
|
"Default",
|
|
"shop"
|
|
],
|
|
"csrf_protection": true
|
|
}
|
|
}
|