mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-06 03:04:40 +02:00
Explicitly call translator interface for form labels.
This helps us to extract the translation keys.
This commit is contained in:
parent
f132c65964
commit
758a2ba25d
16 changed files with 391 additions and 226 deletions
|
@ -46,17 +46,21 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
|||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Translation\Reader\TranslationReader;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class BaseEntityAdminForm extends AbstractType
|
||||
{
|
||||
|
||||
protected $security;
|
||||
protected $params;
|
||||
protected $trans;
|
||||
|
||||
public function __construct(Security $security, ParameterBagInterface $params)
|
||||
public function __construct(Security $security, ParameterBagInterface $params, TranslatorInterface $trans)
|
||||
{
|
||||
$this->security = $security;
|
||||
$this->params = $params;
|
||||
$this->trans = $trans;
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,26 +71,30 @@ class BaseEntityAdminForm extends AbstractType
|
|||
$is_new = $entity->getID() === null;
|
||||
|
||||
$builder
|
||||
->add('name', TextType::class, ['empty_data' => '', 'label' => 'name.label',
|
||||
'attr' => ['placeholder' => 'part.name.placeholder'],
|
||||
->add('name', TextType::class, ['empty_data' => '', 'label' => $this->trans->trans('name.label'),
|
||||
'attr' => ['placeholder' => $this->trans->trans('part.name.placeholder')],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
|
||||
|
||||
->add('parent', StructuralEntityType::class, ['class' => get_class($entity),
|
||||
'required' => false, 'label' => 'parent.label',
|
||||
'required' => false, 'label' => $this->trans->trans('parent.label'),
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ])
|
||||
|
||||
->add('not_selectable', CheckboxType::class, ['required' => false,
|
||||
'label' => 'not_selectable.label', 'help' => 'not_selectable.help', 'label_attr'=> ['class' => 'checkbox-custom'],
|
||||
'label' => $this->trans->trans('entity.edit.not_selectable'),
|
||||
'help' => $this->trans->trans('entity.edit.not_selectable.help'),
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity) ])
|
||||
|
||||
->add('comment', CKEditorType::class, ['required' => false, 'empty_data' => '',
|
||||
'label' => 'comment.label', 'attr' => ['rows' => 4], 'help' => 'bbcode.hint',
|
||||
'label' => $this->trans->trans('comment.label'),
|
||||
'attr' => ['rows' => 4], 'help' => $this->trans->trans('bbcode.hint'),
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
|
||||
$this->additionalFormElements($builder, $options, $entity);
|
||||
|
||||
//Buttons
|
||||
$builder->add('save', SubmitType::class, ['label' => $is_new ? 'entity.create' : 'entity.edit.save',
|
||||
$builder->add('save', SubmitType::class, [
|
||||
'label' => $is_new ? $this->trans->trans('entity.create') : $this->trans->trans('entity.edit.save'),
|
||||
'attr' => ['class' => $is_new ? 'btn-success' : ''],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)])
|
||||
->add('reset', ResetType::class, ['label' => 'entity.edit.reset',
|
||||
|
|
|
@ -45,35 +45,47 @@ class CategoryAdminForm extends BaseEntityAdminForm
|
|||
$is_new = $entity->getID() === null;
|
||||
|
||||
$builder->add('disable_footprints', CheckboxType::class, ['required' => false,
|
||||
'label' => 'disable_footprints.label', 'help' => 'disable_footprints.help', 'label_attr'=> ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
'label' => $this->trans->trans('category.edit.disable_footprints'),
|
||||
'help' => $this->trans->trans('category.edit.disable_footprints.help'),
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
|
||||
$builder->add('disable_manufacturers', CheckboxType::class, ['required' => false,
|
||||
'label' => 'disable_manufacturers.label', 'help' => 'disable_manufacturers.help', 'label_attr'=> ['class' => 'checkbox-custom'],
|
||||
'label' => $this->trans->trans('category.edit.disable_manufacturers'),
|
||||
'help' => $this->trans->trans('category.edit.disable_manufacturers.help'),
|
||||
'label_attr'=> ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
|
||||
$builder->add('disable_autodatasheets', CheckboxType::class, ['required' => false,
|
||||
'label' => 'disable_autodatasheets.label', 'help' => 'disable_autodatasheets.help', 'label_attr'=> ['class' => 'checkbox-custom'],
|
||||
'label' => $this->trans->trans('category.edit.disable_autodatasheets'),
|
||||
'help' => $this->trans->trans('category.edit.disable_autodatasheets.help'),
|
||||
'label_attr'=> ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
|
||||
$builder->add('disable_properties', CheckboxType::class, ['required' => false,
|
||||
'label' => 'disable_properties.label', 'help' => 'disable_properties.help', 'label_attr'=> ['class' => 'checkbox-custom'],
|
||||
'label' => $this->trans->trans('category.edit.disable_properties'),
|
||||
'help' => $this->trans->trans('category.edit.disable_properties.help'),
|
||||
'label_attr'=> ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
|
||||
$builder->add('partname_hint', TextType::class, ['required' => false, 'empty_data' => '',
|
||||
'label' => 'disable_manufacturers.label', 'attr' => ['placeholder' => 'disable_manufacturers.placeholder'],
|
||||
'label' => $this->trans->trans('category.edit.partname_hint'),
|
||||
'attr' => ['placeholder' => $this->trans->trans('category.edit.partname_hint.placeholder')],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
|
||||
$builder->add('partname_regex', TextType::class, ['required' => false, 'empty_data' => '',
|
||||
'label' => 'partname_regex.label', 'attr' => ['placeholder' => 'partname_regex.placeholder'],
|
||||
'label' => $this->trans->trans('category.edit.partname_regex'),
|
||||
'attr' => ['placeholder' => 'category.edit.partname_regex.placeholder'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
|
||||
$builder->add('default_description', TextType::class, ['required' => false, 'empty_data' => '',
|
||||
'label' => 'default_description.label', 'attr' => ['placeholder' => 'default_description.placeholder'],
|
||||
'label' => $this->trans->trans('category.edit.default_description'),
|
||||
'attr' => ['placeholder' => $this->trans->trans('category.edit.default_description.placeholder')],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
|
||||
$builder->add('default_comment', TextType::class, ['required' => false, 'empty_data' => '',
|
||||
'label' => 'default_description.label', 'attr' => ['placeholder' => 'default_comment.placeholder'],
|
||||
'label' => $this->trans->trans('category.edit.default_comment'),
|
||||
'attr' => ['placeholder' => $this->trans->trans('category.edit.default_comment.placeholder')],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
}
|
||||
}
|
|
@ -48,39 +48,48 @@ class CompanyForm extends BaseEntityAdminForm
|
|||
{
|
||||
$is_new = $entity->getID() === null;
|
||||
|
||||
$builder->add('address', TextareaType::class, ['label' => 'company.address.label',
|
||||
$builder->add('address', TextareaType::class, [
|
||||
'label' => $this->trans->trans('company.edit.address'),
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.address.placeholder'], 'required' => false,
|
||||
'attr' => ['placeholder' => $this->trans->trans('company.edit.address.placeholder')], 'required' => false,
|
||||
'empty_data' => ''
|
||||
]);
|
||||
|
||||
$builder->add('phone_number', TelType::class, ['label' => 'company.phone_number.label',
|
||||
$builder->add('phone_number', TelType::class, [
|
||||
'label' => $this->trans->trans('company.edit.phone_number'),
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.phone_number.placeholder'], 'required' => false,
|
||||
'attr' => ['placeholder' => $this->trans->trans('company.edit.phone_number.placeholder')],
|
||||
'required' => false,
|
||||
'empty_data' => ''
|
||||
]);
|
||||
|
||||
$builder->add('fax_number', TelType::class, ['label' => 'company.fax_number.label',
|
||||
$builder->add('fax_number', TelType::class, [
|
||||
'label' => $this->trans->trans('company.edit.fax_number'),
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.fax_number.placeholder'], 'required' => false,
|
||||
'empty_data' => ''
|
||||
]);
|
||||
|
||||
$builder->add('email_address', EmailType::class, ['label' => 'company.email.label',
|
||||
$builder->add('email_address', EmailType::class, [
|
||||
'label' => $this->trans->trans('company.edit.email'),
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.email.placeholder'], 'required' => false,
|
||||
'attr' => ['placeholder' => $this->trans->trans('company.edit.email.placeholder')], 'required' => false,
|
||||
'empty_data' => ''
|
||||
]);
|
||||
|
||||
$builder->add('website', UrlType::class, ['label' => 'company.website.label',
|
||||
$builder->add('website', UrlType::class, [
|
||||
'label' => $this->trans->trans('company.edit.website'),
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.website.placeholder'], 'required' => false,
|
||||
'attr' => ['placeholder' => $this->trans->trans('company.edit.website.placeholder')], 'required' => false,
|
||||
'empty_data' => ''
|
||||
]);
|
||||
|
||||
$builder->add('auto_product_url', UrlType::class, ['label' => 'company.auto_product_url.label',
|
||||
$builder->add('auto_product_url', UrlType::class, [
|
||||
'label' => $this->trans->trans('company.edit.auto_product_url'),
|
||||
'help' => $this->trans->trans('company.edit.auto_product_url.help'),
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.auto_product_url.placeholder'], 'required' => false,
|
||||
'attr' => ['placeholder' => $this->trans->trans('company.edit.auto_product_url.placeholder')],
|
||||
'required' => false,
|
||||
'empty_data' => ''
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -44,15 +44,17 @@ class CurrencyAdminForm extends BaseEntityAdminForm
|
|||
{
|
||||
$is_new = $entity->getID() === null;
|
||||
|
||||
$builder->add('iso_code', CurrencyType::class , ['required' => true,
|
||||
$builder->add('iso_code', CurrencyType::class, [
|
||||
'required' => false,
|
||||
'label' => 'currency.iso_code.label',
|
||||
'label' => $this->trans->trans('currency.edit.iso_code'),
|
||||
'preferred_choices' => ['EUR', 'USD', 'GBP', 'JPY', 'CNY'],
|
||||
'attr' => ['class' => 'selectpicker', 'data-live-search' => true],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
|
||||
$builder->add('exchange_rate', MoneyType::class, ['required' => false,
|
||||
'label' => 'currency.exchange_rate.label', 'currency' => $this->params->get('default_currency'),
|
||||
$builder->add('exchange_rate', MoneyType::class, [
|
||||
'required' => false,
|
||||
'label' => $this->trans->trans('currency.edit.exchange_rate'),
|
||||
'currency' => $this->params->get('default_currency'),
|
||||
'scale' => 6,
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace App\Form\AdminPages;
|
|||
|
||||
|
||||
use App\Entity\Base\StructuralDBElement;
|
||||
use App\Form\Type\StructuralEntityType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Bundle\MakerBundle\Str;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
|
@ -43,15 +44,18 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
|||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class ImportType extends AbstractType
|
||||
{
|
||||
|
||||
protected $security;
|
||||
protected $trans;
|
||||
|
||||
public function __construct(Security $security)
|
||||
public function __construct(Security $security, TranslatorInterface $trans)
|
||||
{
|
||||
$this->security = $security;
|
||||
$this->trans = $trans;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
|
@ -60,31 +64,42 @@ class ImportType extends AbstractType
|
|||
$data = $options['data'];
|
||||
|
||||
//Disable import if user is not allowed to create elements.
|
||||
$entity = new $data['entity_class'];
|
||||
$entity = new $data['entity_class']();
|
||||
$perm_name = "create";
|
||||
$disabled = ! $this->security->isGranted($perm_name, $entity);
|
||||
|
||||
$builder
|
||||
|
||||
->add('format', ChoiceType::class, ['choices' =>
|
||||
['JSON' => 'json', 'XML' => 'xml','CSV'=>'csv' ,'YAML' => 'yaml'], 'label' => 'export.format',
|
||||
->add('format', ChoiceType::class, [
|
||||
'choices' => ['JSON' => 'json', 'XML' => 'xml','CSV' => 'csv' ,'YAML' => 'yaml'],
|
||||
'label' => $this->trans->trans('export.format'),
|
||||
'disabled' => $disabled])
|
||||
->add('csv_separator', TextType::class, ['data' => ';', 'label' => 'import.csv_separator',
|
||||
->add('csv_separator', TextType::class, ['data' => ';',
|
||||
'label' => $this->trans->trans('import.csv_separator'),
|
||||
'disabled' => $disabled]);
|
||||
if($entity instanceof StructuralDBElement) {
|
||||
$builder->
|
||||
add('parent', EntityType::class, ['class' => $data['entity_class'], 'choice_label' => 'full_path',
|
||||
'attr' => ['class' => 'selectpicker', 'data-live-search' => true], 'required' => false,
|
||||
'label' => 'parent.label', 'disabled' => $disabled]);
|
||||
}
|
||||
$builder->add('file', FileType::class, ['label' => 'import.file',
|
||||
'attr' => ['class' => 'file', 'data-show-preview' => 'false', 'data-show-upload' => 'false'], 'disabled' => $disabled])
|
||||
|
||||
if ($entity instanceof StructuralDBElement) {
|
||||
$builder->add('parent', StructuralEntityType::class, [
|
||||
'class' => $data['entity_class'],
|
||||
'required' => false,
|
||||
'label' => $this->trans->trans('parent.label'),
|
||||
'disabled' => $disabled
|
||||
]);
|
||||
}
|
||||
|
||||
$builder->add('file', FileType::class, [
|
||||
'label' => $this->trans->trans('import.file'),
|
||||
'attr' => ['class' => 'file', 'data-show-preview' => 'false', 'data-show-upload' => 'false'],
|
||||
'disabled' => $disabled
|
||||
])
|
||||
|
||||
->add('preserve_children', CheckboxType::class, ['data' => true, 'required' => false,
|
||||
'label' => 'import.preserve_children', 'label_attr'=> ['class' => 'checkbox-custom'], 'disabled' => $disabled])
|
||||
'label' => $this->trans->trans('import.preserve_children'),
|
||||
'label_attr' => ['class' => 'checkbox-custom'], 'disabled' => $disabled])
|
||||
->add('abort_on_validation_error', CheckboxType::class, ['data' => true, 'required' => false,
|
||||
'label' => 'import.abort_on_validation', 'help'=> 'import.abort_on_validation.help',
|
||||
'label_attr'=> ['class' => 'checkbox-custom'], 'disabled' => $disabled])
|
||||
'label' => $this->trans->trans('import.abort_on_validation'),
|
||||
'help' => $this->trans->trans('import.abort_on_validation.help'),
|
||||
'label_attr' => ['class' => 'checkbox-custom'], 'disabled' => $disabled])
|
||||
|
||||
//Buttons
|
||||
->add('import', SubmitType::class, ['label' => 'import.btn', 'disabled' => $disabled]);
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace App\Form\AdminPages;
|
|||
|
||||
|
||||
use App\Entity\Base\StructuralDBElement;
|
||||
use App\Form\Type\StructuralEntityType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
|
@ -43,14 +44,17 @@ use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
|||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class MassCreationForm extends AbstractType
|
||||
{
|
||||
protected $security;
|
||||
protected $translator;
|
||||
|
||||
public function __construct(Security $security)
|
||||
public function __construct(Security $security, TranslatorInterface $translator)
|
||||
{
|
||||
$this->security = $security;
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
|
@ -64,18 +68,26 @@ class MassCreationForm extends AbstractType
|
|||
$disabled = ! $this->security->isGranted($perm_name, $entity);
|
||||
|
||||
$builder
|
||||
->add('lines', TextareaType::class, ['data' => '', 'label' => 'mass_creation.lines',
|
||||
->add('lines', TextareaType::class, ['data' => '',
|
||||
'label' => $this->translator->trans('mass_creation.lines'),
|
||||
'disabled' => $disabled, 'required' => true,
|
||||
'attr' => ['placeholder' => 'mass_creation.lines.placeholder', 'rows' => 10]]);
|
||||
'attr' => [
|
||||
'placeholder' => $this->translator->trans('mass_creation.lines.placeholder'),
|
||||
'rows' => 10
|
||||
]
|
||||
]);
|
||||
if ($entity instanceof StructuralDBElement) {
|
||||
$builder->
|
||||
add('parent', EntityType::class, ['class' => $data['entity_class'], 'choice_label' => 'full_path',
|
||||
'attr' => ['class' => 'selectpicker', 'data-live-search' => true], 'required' => false,
|
||||
'label' => 'parent.label', 'disabled' => $disabled]);
|
||||
$builder->add('parent', StructuralEntityType::class, [
|
||||
'class' => $data['entity_class'],
|
||||
'required' => false,
|
||||
'label' => $this->translator->trans('parent.label'),
|
||||
'disabled' => $disabled]);
|
||||
}
|
||||
|
||||
$builder
|
||||
//Buttons
|
||||
->add('create', SubmitType::class, ['label' => 'mass_creation.btn', 'disabled' => $disabled]);
|
||||
//Buttons
|
||||
$builder->add('create', SubmitType::class, [
|
||||
'label' => $this->translator->trans('entity.mass_creation.btn'),
|
||||
'disabled' => $disabled
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -45,18 +45,20 @@ class MeasurementUnitAdminForm extends BaseEntityAdminForm
|
|||
$is_new = $entity->getID() === null;
|
||||
|
||||
$builder->add('is_integer', CheckboxType::class, ['required' => false,
|
||||
'label' => 'measurement_unit.is_integer.label', 'help' => 'measurement_unit.is_integer.help',
|
||||
'label_attr'=> ['class' => 'checkbox-custom'],
|
||||
'label' => $this->trans->trans('measurement_unit.edit.is_integer'),
|
||||
'help' => $this->trans->trans('measurement_unit.edit.is_integer.help'),
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
|
||||
$builder->add('use_si_prefix', CheckboxType::class, ['required' => false,
|
||||
'label' => 'measurement_unit.use_si_prefix.label', 'help' => 'measurement_unit.use_si_prefix.help',
|
||||
'label_attr'=> ['class' => 'checkbox-custom'],
|
||||
'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'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
|
||||
$builder->add('unit', TextType::class, ['required' => false,
|
||||
'label' => 'measurement_unit.unit.label', 'attr' => ['placeholder' => 'measurement_unit.unit.placeholder'],
|
||||
'label' => $this->trans->trans('measurement_unit.edit.unit_symbol'),
|
||||
'attr' => ['placeholder' => $this->trans->trans('measurement_unit.edit.unit_symbol.placeholder')],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
|
||||
}
|
||||
}
|
|
@ -46,23 +46,31 @@ class StorelocationAdminForm extends BaseEntityAdminForm
|
|||
{
|
||||
$is_new = $entity->getID() === null;
|
||||
|
||||
$builder->add('is_full', CheckboxType::class, ['required' => false,
|
||||
'label' => 'storelocation.is_full.label', 'help' => 'storelocation.is_full.help',
|
||||
'label_attr'=> ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity)]);
|
||||
|
||||
$builder->add('limit_to_existing_parts', CheckboxType::class, ['required' => false,
|
||||
'label' => 'storelocation.limit_to_existing.label', 'help' => 'storelocation.limit_to_existing.help',
|
||||
'label_attr'=> ['class' => 'checkbox-custom'],
|
||||
$builder->add('is_full', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => $this->trans->trans('storelocation.edit.is_full.label'),
|
||||
'help' => $this->trans->trans('storelocation.edit.is_full.help'),
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity)]);
|
||||
|
||||
$builder->add('only_single_part', CheckboxType::class, ['required' => false,
|
||||
'label' => 'storelocation.only_single_part.label', 'help' => 'storelocation.only_single_part.help',
|
||||
'label_attr'=> ['class' => 'checkbox-custom'],
|
||||
$builder->add('limit_to_existing_parts', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => $this->trans->trans('storelocation.limit_to_existing.label'),
|
||||
'help' => $this->trans->trans('storelocation.limit_to_existing.help'),
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity)]);
|
||||
|
||||
$builder->add('storage_type', StructuralEntityType::class, ['required' => false,
|
||||
'label' => 'storelocation.storage_type.label', 'help' => 'storelocation.storage_type.help',
|
||||
$builder->add('only_single_part', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => $this->trans->trans('storelocation.only_single_part.label'),
|
||||
'help' => $this->trans->trans('storelocation.only_single_part.help'),
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity)]);
|
||||
|
||||
$builder->add('storage_type', StructuralEntityType::class, [
|
||||
'required' => false,
|
||||
'label' => $this->trans->trans('storelocation.storage_type.label'),
|
||||
'help' => $this->trans->trans('storelocation.storage_type.help'),
|
||||
'class' => MeasurementUnit::class, 'disable_not_selectable' => true,
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity)]);
|
||||
|
||||
|
|
|
@ -47,55 +47,26 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
|
|||
use Symfony\Component\Form\Extension\Core\Type\UrlType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class SupplierForm extends BaseEntityAdminForm
|
||||
class SupplierForm extends CompanyForm
|
||||
{
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
{
|
||||
$is_new = $entity->getID() === null;
|
||||
|
||||
$builder->add('address', TextareaType::class, ['label' => 'company.address.label',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.address.placeholder'], 'required' => false,
|
||||
'empty_data' => ''
|
||||
]);
|
||||
parent::additionalFormElements($builder, $options, $entity);
|
||||
|
||||
$builder->add('phone_number', TelType::class, ['label' => 'company.phone_number.label',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.phone_number.placeholder'], 'required' => false,
|
||||
'empty_data' => ''
|
||||
]);
|
||||
$builder->add('default_currency', StructuralEntityType::class, [
|
||||
'class' => Currency::class,
|
||||
'required' => false,
|
||||
'label' => $this->trans->trans('supplier.edit.default_currency'),
|
||||
'disable_not_selectable' => true,
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
|
||||
|
||||
$builder->add('fax_number', TelType::class, ['label' => 'company.fax_number.label',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.fax_number.placeholder'], 'required' => false,
|
||||
'empty_data' => ''
|
||||
]);
|
||||
|
||||
$builder->add('email_address', EmailType::class, ['label' => 'company.email.label',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.email.placeholder'], 'required' => false,
|
||||
'empty_data' => ''
|
||||
]);
|
||||
|
||||
$builder->add('website', UrlType::class, ['label' => 'company.website.label',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.website.placeholder'], 'required' => false,
|
||||
'empty_data' => ''
|
||||
]);
|
||||
|
||||
$builder->add('auto_product_url', UrlType::class, ['label' => 'company.auto_product_url.label',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.auto_product_url.placeholder'], 'required' => false,
|
||||
'empty_data' => ''
|
||||
]);
|
||||
|
||||
$builder->add('default_currency', StructuralEntityType::class, ['class' => Currency::class,
|
||||
'required' => false, 'label' => 'supplier.default_currency.label', 'disable_not_selectable' => true,
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
|
||||
|
||||
$builder->add('shipping_costs', MoneyType::class, [ 'required' => false,
|
||||
'currency' => $this->params->get('default_currency'), 'scale' => 3,
|
||||
'label' => 'supplier.shipping_costs.label',
|
||||
$builder->add('shipping_costs', MoneyType::class, [
|
||||
'required' => false,
|
||||
'currency' => $this->params->get('default_currency'),
|
||||
'scale' => 3,
|
||||
'label' => $this->trans->trans('supplier.shipping_costs.label'),
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity)
|
||||
]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue