Module Recettes : on avance encore...

This commit is contained in:
2021-04-28 20:37:58 +02:00
parent 9976d2ff76
commit 375e4e5d49
26 changed files with 657 additions and 99 deletions

View File

@@ -3,7 +3,12 @@
namespace Recettes\Form;
use Recettes\Recettes;
use Symfony\Component\Validator\Constraints\AbstractComparison;
use Symfony\Component\Validator\Constraints\GreaterThan;
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
use Symfony\Component\Validator\Constraints\LessThanOrEqual;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Range;
use Thelia\Core\Translation\Translator;
use Thelia\Form\BaseForm;
@@ -33,10 +38,7 @@ class RecetteCreateForm extends BaseForm
"content_id",
"integer",
[
"label" => $this->trans("Content Id"),
"constraints" => [
new NotBlank()
]
"constraints" => [ new NotBlank() ]
]
)
->add(
@@ -45,29 +47,25 @@ class RecetteCreateForm extends BaseForm
[
"label" => $this->trans("Title"),
"label_attr" => [
"for" => "attr-title"
"for" => "title"
],
"constraints" => [
new NotBlank()
]
"constraints" => [ new NotBlank() ],
"required" => true
]
)
->add(
"difficulty",
"choice",
"integer",
[
"choices" => array(
"Facile",
"Moyen",
"Difficile"
),
"label" => $this->trans("Difficulty"),
"label_attr" => [
"for" => "attr-difficulty"
"for" => "difficulty"
],
"constraints" => [
new NotBlank()
]
new GreaterThanOrEqual(array('value' => 0)),
new LessThanOrEqual(array('value' => 2))
],
"required" => true
]
)
->add(
@@ -76,11 +74,10 @@ class RecetteCreateForm extends BaseForm
[
"label" => $this->trans("Number of people"),
"label_attr" => [
"for" => "attr-difficulty"
"for" => "people"
],
"constraints" => [
new NotBlank()
]
"constraints" => [ new GreaterThan(array('value' => 0)) ],
"required" => true
]
)
->add(
@@ -89,12 +86,11 @@ class RecetteCreateForm extends BaseForm
[
"label" => $this->trans("Preparation time"),
"label_attr" => [
"for" => "attr-preparation-time",
"for" => "preparation_time",
"help" => "ex : 1h15 ou 45 minutes"
],
"constraints" => [
new NotBlank()
]
"constraints" => [ new NotBlank() ],
"required" => true
]
)
->add(
@@ -103,7 +99,7 @@ class RecetteCreateForm extends BaseForm
[
"label" => $this->trans("Cooking time"),
"label_attr" => [
"for" => "attr-cooking-time",
"for" => "cooking_time",
"help" => "ex : 1h15 ou 45 minutes"
],
"required" => false
@@ -115,10 +111,7 @@ class RecetteCreateForm extends BaseForm
[
"label" => $this->trans("Steps"),
"label_attr" => [
"for" => "attr-recipe"
],
"constraints" => [
new NotBlank()
"for" => "steps"
]
]
);

View File

@@ -1,30 +0,0 @@
<?php
namespace Recettes\Form;
use Thelia\Core\Translation\Translator;
/**
* Class RecetteUpdateForm
* @package Recettes\Form
*/
class RecetteUpdateForm extends RecetteCreateForm
{
/** @var Translator $translator */
protected $translator;
/**
* @return string the name of you form. This name must be unique
*/
public function getName()
{
return 'recette_update_form';
}
protected function buildForm()
{
parent::buildForm();
}
}