Files
kimai/src/TimesheetBundle/Form/ProjectEditForm.php
Kevin Papst 79e87ecdbe added toolbar to customer screen #28 (#49)
* fixed filter query #28
* fixed annotation #28
* merge message files #28
* added page size type #28
* added visibility type #28
* added filter toolbar to customer screen #28
2018-01-07 21:42:27 +01:00

88 lines
2.5 KiB
PHP

<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace TimesheetBundle\Form;
use AppBundle\Form\Type\VisibilityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use TimesheetBundle\Entity\Customer;
use TimesheetBundle\Entity\Project;
use TimesheetBundle\Form\Type\CustomerType;
/**
* Defines the form used to edit Projects.
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class ProjectEditForm extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
// string - length 255
->add('name', TextType::class, [
'label' => 'label.name',
])
// text
->add('comment', TextareaType::class, [
'label' => 'label.comment',
])
// customer
->add('customer', CustomerType::class, [
'label' => 'label.customer',
])
// boolean
->add('visible', VisibilityType::class, [
'label' => 'label.visible',
])
// string
->add('budget', MoneyType::class, [
'label' => 'label.budget',
'currency' => $builder->getOption('currency'),
])
// do not allow activity selection as this causes headaches:
// 1. it is a bad UX
// 2. what should happen if they are detached?
/*
->add('activities', EntityType::class, [
'label' => 'label.activity',
'class' => 'TimesheetBundle:Activity',
'multiple' => true,
'expanded' => true
])
*/
;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Project::class,
'csrf_protection' => true,
'csrf_field_name' => '_token',
'csrf_token_id' => 'admin_project_edit',
'currency' => Customer::DEFAULT_CURRENCY,
]);
}
}