vibe
This commit is contained in:
parent
16533b1495
commit
ab0677c463
14 changed files with 705 additions and 38 deletions
|
@ -25,7 +25,7 @@ class BulkEditDrinkTypeStockForm extends AbstractType
|
|||
'by_reference' => false,
|
||||
])
|
||||
->add('save', SubmitType::class, [
|
||||
'label' => 'Update Wanted Stock Levels',
|
||||
'label' => 'Update Current Stock Levels',
|
||||
'attr' => [
|
||||
'class' => 'btn btn-primary',
|
||||
],
|
||||
|
|
41
src/Form/BulkEditDrinkTypeWantedStockForm.php
Normal file
41
src/Form/BulkEditDrinkTypeWantedStockForm.php
Normal 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 BulkEditDrinkTypeWantedStockForm extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('drinkTypes', CollectionType::class, [
|
||||
'entry_type' => DrinkTypeWantedStockEditType::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,
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -11,6 +11,8 @@ 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;
|
||||
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
class DrinkTypeStockEditType extends AbstractType
|
||||
{
|
||||
|
@ -26,13 +28,22 @@ class DrinkTypeStockEditType extends AbstractType
|
|||
'readonly' => true,
|
||||
],
|
||||
])
|
||||
->add('wantedStock', NumberType::class, [
|
||||
'label' => 'Wanted Stock',
|
||||
->add('currentStock', NumberType::class, [
|
||||
'label' => 'Current Stock',
|
||||
'attr' => [
|
||||
'min' => 0,
|
||||
'step' => 1,
|
||||
'class' => 'form-control',
|
||||
],
|
||||
'constraints' => [
|
||||
new NotBlank([
|
||||
'message' => 'Current stock cannot be blank',
|
||||
]),
|
||||
new GreaterThanOrEqual([
|
||||
'value' => 0,
|
||||
'message' => 'Current stock must not be negative',
|
||||
]),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
56
src/Form/DrinkTypeWantedStockEditType.php
Normal file
56
src/Form/DrinkTypeWantedStockEditType.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?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;
|
||||
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
class DrinkTypeWantedStockEditType 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',
|
||||
],
|
||||
'constraints' => [
|
||||
new NotBlank([
|
||||
'message' => 'Wanted stock cannot be blank',
|
||||
]),
|
||||
new GreaterThanOrEqual([
|
||||
'value' => 0,
|
||||
'message' => 'Wanted stock must not be negative',
|
||||
]),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => DrinkType::class,
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue