get ready

This commit is contained in:
lubiana 2025-06-11 20:28:45 +02:00
parent ca9819a436
commit 6b0a478ca5
Signed by: lubiana
SSH key fingerprint: SHA256:vW1EA0fRR3Fw+dD/sM0K+x3Il2gSry6YRYHqOeQwrfk
16 changed files with 395 additions and 124 deletions

View file

@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class BulkEditDrinkTypeStockForm extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('drinkTypes', CollectionType::class, [
'entry_type' => DrinkTypeStockEditType::class,
'entry_options' => [
'label' => false,
],
'allow_add' => false,
'allow_delete' => false,
'by_reference' => false,
])
->add('save', SubmitType::class, [
'label' => 'Update Wanted Stock Levels',
'attr' => [
'class' => 'btn btn-primary',
],
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => null,
]);
}
}

View file

@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace App\Form;
use App\Entity\DrinkType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class DrinkTypeStockEditType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('id', HiddenType::class, [
'mapped' => false,
])
->add('name', TextType::class, [
'disabled' => true,
'attr' => [
'readonly' => true,
],
])
->add('wantedStock', NumberType::class, [
'label' => 'Wanted Stock',
'attr' => [
'min' => 0,
'step' => 1,
'class' => 'form-control',
],
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => DrinkType::class,
]);
}
}