<?php

namespace PointRetrait\Form;

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

/**
 * Class CreatePlaceForm
 * @package PointRetrait\Form
 */
class CreatePlaceForm extends BaseForm
{
    /**
     * @inheritDoc
     */
    protected function buildForm()
    {
        $this->formBuilder
            ->add(
                "title",
                "text",
                [
                    "required" => true,
                    "constraints" => [new Constraints\NotBlank()],
                    "label" => $this->translator->trans('Place name', [], PointRetrait::DOMAIN_NAME),
                    "label_attr" => ['for' => 'title']
                ])
            ->add(
                "price",
                "number",
                [
                    "required" => true,
                    "constraints" => [new GreaterThanOrEqual(["value" => 0])],
                    "label" => $this->translator->trans('Withdrawal price', [], PointRetrait::DOMAIN_NAME),
                    "label_attr" => ['for' => 'price']
                ])
            ->add(
                "minimum_amount",
                "number",
                [
                    "required" => true,
                    "constraints" => [new GreaterThanOrEqual(["value" => 0])],
                    "label" => $this->translator->trans('Minimum amount', [], PointRetrait::DOMAIN_NAME),
                    "label_attr" => ['for' => 'minimum_amount']
                ])
            ->add(
                "address1","text",
                [
                    "required" => true,
                    "constraints" => [new Constraints\NotBlank()],
                    "label" => $this->translator->trans('Address1', [], PointRetrait::DOMAIN_NAME),
                    "label_attr" => ['for' => 'address1']
                ])
            ->add(
                "address2","text",
                [
                    "required" => false,
                    "label" => $this->translator->trans('Address2', [], PointRetrait::DOMAIN_NAME),
                    "label_attr" => ['for' => 'address2']
                ])
            ->add(
                "zipcode","text",
                [
                    "required" => true,
                    "constraints" => [new Constraints\NotBlank()],
                    "label" => $this->translator->trans('Zipcode', [], PointRetrait::DOMAIN_NAME),
                    "label_attr" => ['for' => 'zipcode']
                ])
            ->add(
                "city","text",
                [
                    "required" => true,
                    "constraints" => [new Constraints\NotBlank()],
                    "label" => $this->translator->trans('City', [], PointRetrait::DOMAIN_NAME),
                    "label_attr" => ['for' => 'city']
                ])
            ->add(
                "active",
                "number",
                [
                    "required" => true
                ]
            );
    }

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