<?php

namespace LivraisonParSecteurs\Form;

use LivraisonParSecteurs\LivraisonParSecteurs;
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
use Thelia\Form\BaseForm;
use Symfony\Component\Validator\Constraints;

/**
 * Class CreateForm
 * @package LivraisonParSecteurs\Form
 */
class CreateForm extends BaseForm
{
    /**
     * @inheritDoc
     */
    protected function buildForm()
    {
        $this->formBuilder
            ->add(
                "title",
                "text",
                [
                    "required" => true,
                    "constraints" => [new Constraints\NotBlank()],
                    "label" => $this->translator->trans('Area name', [], LivraisonParSecteurs::DOMAIN_NAME),
                    "label_attr" => ['for' => 'title']
                ])
            ->add(
                "price",
                "number",
                [
                    "required" => true,
                    "constraints" => [new GreaterThanOrEqual(["value" => 0])],
                    "label" => $this->translator->trans('Delivery price', [], LivraisonParSecteurs::DOMAIN_NAME),
                    "label_attr" => ['for' => 'price']
                ])
            ->add(
                "minimum_amount",
                "number",
                [
                    "required" => true,
                    "constraints" => [new GreaterThanOrEqual(["value" => 0])],
                    "label" => $this->translator->trans('Minimum amount', [], LivraisonParSecteurs::DOMAIN_NAME),
                    "label_attr" => ['for' => 'minimum_amount']
                ])
            ->add(
                "active",
                "number",
                [
                    "required" => true
                ]
            );
    }

    /**
     * @inheritDoc
     */
    public function getName()
    {
        return "lps-area-create";
    }
}
