2019-08-14 18:31:46 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2019-11-09 00:47:20 +01:00
|
|
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
2019-08-14 18:31:46 +02:00
|
|
|
*
|
2019-11-01 13:40:30 +01:00
|
|
|
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
2019-08-14 18:31:46 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Form\AdminPages;
|
|
|
|
|
|
|
|
use App\Entity\Base\NamedDBElement;
|
|
|
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
|
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
|
|
|
|
|
|
class MeasurementUnitAdminForm extends BaseEntityAdminForm
|
|
|
|
{
|
|
|
|
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
|
|
|
{
|
2019-11-09 00:47:20 +01:00
|
|
|
$is_new = null === $entity->getID();
|
2019-08-14 18:31:46 +02:00
|
|
|
|
|
|
|
$builder->add('is_integer', CheckboxType::class, ['required' => false,
|
2019-11-09 00:47:20 +01:00
|
|
|
'label' => $this->trans->trans('measurement_unit.edit.is_integer'),
|
2019-09-04 15:53:18 +02:00
|
|
|
'help' => $this->trans->trans('measurement_unit.edit.is_integer.help'),
|
|
|
|
'label_attr' => ['class' => 'checkbox-custom'],
|
2019-11-09 00:47:20 +01:00
|
|
|
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
2019-08-14 18:31:46 +02:00
|
|
|
|
|
|
|
$builder->add('use_si_prefix', CheckboxType::class, ['required' => false,
|
2019-09-04 15:53:18 +02:00
|
|
|
'label' => $this->trans->trans('measurement_unit.edit.use_si_prefix'),
|
|
|
|
'help' => $this->trans->trans('measurement_unit.edit.use_si_prefix.help'),
|
|
|
|
'label_attr' => ['class' => 'checkbox-custom'],
|
2019-11-09 00:47:20 +01:00
|
|
|
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
2019-08-14 18:31:46 +02:00
|
|
|
|
|
|
|
$builder->add('unit', TextType::class, ['required' => false,
|
2019-09-04 15:53:18 +02:00
|
|
|
'label' => $this->trans->trans('measurement_unit.edit.unit_symbol'),
|
|
|
|
'attr' => ['placeholder' => $this->trans->trans('measurement_unit.edit.unit_symbol.placeholder')],
|
2019-11-09 00:47:20 +01:00
|
|
|
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
2019-08-14 18:31:46 +02:00
|
|
|
}
|
2019-11-09 00:47:20 +01:00
|
|
|
}
|