<?php
namespace App\Form;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class WayBillExpense extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder
->add('amount', IntegerType::class)
->add('expenseType', EntityType::class, [
'class' => 'App\Entity\ExpenseType',
'query_builder' => function (EntityRepository $er){
return $er->createQueryBuilder('e')
->andWhere('e.isAutomatic = false')
->andWhere('e.isWayBill = true');
}
]);
}
public function configureOptions(OptionsResolver $resolver) {
$resolver->setDefaults([
'data_class' => 'App\Entity\TransactionExpense'
]);
}
public function getBlockPrefix()
{
return 'app_bundle_way_bill_expense';
}
}