<?php

namespace LivraisonParSecteurs\Form;

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

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

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