<?php
namespace App\Ox\HoardBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use App\Ox\HoardBundle\Form\DataTransformer\FileToHoardImageTransformer;
use App\Ox\HoardBundle\Form\HoardImageType;
use App\Ox\HoardBundle\Form\HoardReferenceType;
class SearchType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('hoardFindSpotName', TextType::class, array(
'required' => false,
))
->add('hoardAddress', TextType::class, array(
'required' => false
))
->add('hoardCity', TextType::class, array(
'required' => false
))
->add('hoardCounty', TextType::class, array(
'required' => false
))
->add('hoardRegion', TextType::class, array(
'required' => false
))
->add('hoardReference', EntityType::class, array(
'class' => 'OxHoardBundle:Reference',
'required' => false,
'multiple' => true,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('r');
$qb->orderBy('r.sortValue', 'DESC')
->addOrderBy('r.title', 'ASC');
return $qb;
}
))
->add('hoardFindSpotRating', EntityType::class, array(
'class' => 'OxHoardBundle:Rating',
'required' => false,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('h');
$qb->orderBy('h.sortValue', 'DESC')
->addOrderBy('h.rating', 'ASC');
return $qb;
}
))
->add('hoardCoinLevelData', EntityType::class, array(
'class' => 'OxHoardBundle:CoinLevelData',
'required' => false,
'query_builder' => function($repository) {
return $repository->createQueryBuilder('h');
}
))
->add('hoardType', EntityType::class, array(
'class' => 'OxHoardBundle:HoardType',
'required' => false,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('h');
$qb->orderBy('h.sortValue', 'DESC')
->addOrderBy('h.hoardType', 'ASC');
return $qb;
}
))
->add('hoardCountries', EntityType::class, array(
'class' => 'OxHoardBundle:Country',
'multiple' => true,
'required' => false,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('c');
$qb->orderBy('c.country', 'ASC');
return $qb;
}
))
->add('hoardProvince', EntityType::class, array(
'class' => 'OxHoardBundle:Province',
'required' => false,
'disabled' => true,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('p');
$qb->orderBy('p.province', 'ASC');
return $qb;
}
))
->add('hoardAncientPlace', EntityType::class, array(
'class' => 'App\Ox\HoardBundle\Entity\AncientPlace',
'required' => false,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('p');
$qb->orderBy('p.ancientPlace', 'ASC');
return $qb;
}
))
// ->add('hoardFindSpotLocationDetail', EntityType::class, array(
// 'class' => 'App\Ox\HoardBundle\Entity\FindSpotLocationDetail',
// 'required' => false,
// 'query_builder' => function($repository) {
// $qb = $repository->createQueryBuilder('p');
// $qb->orderBy('p.findSpotLocationDetail', 'ASC');
// return $qb;
// }
// ))
// ->add('hoardDiscoveryMethod', EntityType::class, array(
// 'class' => 'OxHoardBundle:DiscoveryMethod',
// 'required' => false,
// 'query_builder' => function($repository) {
// $qb = $repository->createQueryBuilder('h');
// $qb->orderBy('h.discoveryMethod', 'ASC');
// return $qb;
// }
// ))
// ->add('hoardDiscoveryLandUse', EntityType::class, array(
// 'class' => 'OxHoardBundle:DiscoveryLandUse',
// 'required' => false,
// 'query_builder' => function($repository) {
// $qb = $repository->createQueryBuilder('h');
// $qb->orderBy('h.discoveryLandUse', 'ASC');
// return $qb;
// }
// ))
// ->add('hoardFindSpotComment', TextType::class, array(
// 'required' => false,
// ))
->add('hoardInternalNote', TextType::class, array(
'required' => false,
))
// ->add('hoardOwner', TextType::class, array(
// 'required' => false,
// ))
// ->add('hoardFinder', TextType::class, array(
// 'required' => false,
// ))
->add('hoardClosingReign1', EntityType::class, array(
'class' => 'OxHoardBundle:Reign',
'required' => false,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('r');
$qb->orderBy('r.startDate, r.endDate', 'ASC');
return $qb;
}
))
->add('hoardClosingReign2', EntityType::class, array(
'class' => 'OxHoardBundle:Reign',
'required' => false,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('r');
$qb->orderBy('r.startDate, r.endDate', 'ASC');
return $qb;
}
))
->add('hoardRating', EntityType::class, array(
'class' => 'OxHoardBundle:Rating',
'required' => false,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('h');
$qb->orderBy('h.sortValue', 'DESC')
->addOrderBy('h.rating', 'ASC');
return $qb;
}
))
->add('hoardContextualRating', EntityType::class, array(
'class' => 'OxHoardBundle:Rating',
'required' => false,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('h');
$qb->orderBy('h.sortValue', 'DESC')
->addOrderBy('h.rating', 'ASC');
return $qb;
}
))
// ->add('hoardArchaeologyNaturalFeatures', TextType::class, array(
// 'required' => false,
// ))
// ->add('hoardArchaeologySiteComment', TextType::class, array(
// 'required' => false,
// ))
// ->add('hoardArchaeologyAssociatedFeatures', TextType::class, array(
// 'required' => false,
// ))
// ->add('hoardArchaeologyRecoveryMethod', EntityType::class, array(
// 'class' => 'OxHoardBundle:ArchaeologyRecoveryMethod',
// 'multiple' => true,
// 'required' => false,
// 'query_builder' => function($repository) {
// $qb = $repository->createQueryBuilder('h');
// $qb->orderBy('h.archaeologyRecoveryMethod', 'ASC');
// return $qb;
// }
// ))
->add('hoardArchaeologySiteContext', EntityType::class, array(
'class' => 'OxHoardBundle:ArchaeologySiteContext',
'multiple' => true,
'required' => false,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('h');
$qb->orderBy('h.sortValue', 'DESC')
->addOrderBy('h.archaeologySiteContext', 'ASC');
return $qb;
}
))
->add('hoardArchaeologyContextNatures', EntityType::class, array(
'class' => 'OxHoardBundle:ArchaeologyContextNature',
'multiple' => true,
'required' => false,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('h');
$qb->orderBy('h.title', 'ASC');
return $qb;
}
))
->add('hoardArchaeologySiteContextDetails', EntityType::class, array(
'class' => 'OxHoardBundle:ArchaeologySiteContextDetail',
'multiple' => true,
'required' => false,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('c');
$qb->orderBy('c.archaeologySiteContextDetail', 'ASC');
return $qb;
}
))
// ->add('hoardArchaeologyPeriod', EntityType::class, array(
// 'class' => 'OxHoardBundle:ArchaeologyPeriod',
// 'required' => false,
// 'query_builder' => function($repository) {
// $qb = $repository->createQueryBuilder('h');
// $qb->orderBy('h.archaeologyPeriod', 'ASC');
// return $qb;
// }
// ))
// ->add('hoardArchaeologyEndPeriod', EntityType::class, array(
// 'class' => 'OxHoardBundle:ArchaeologyPeriod',
// 'required' => false,
// 'query_builder' => function($repository) {
// $qb = $repository->createQueryBuilder('h');
// $qb->orderBy('h.archaeologyPeriod', 'ASC');
// return $qb;
// }
// ))
->add('hoardHasImage', CheckboxType::class, array(
'required' => false,
))
// ->add('hoardHideWhat', EntityType::class, array(
// 'class' => 'OxHoardBundle:HideWhat',
// 'required' => false,
// 'query_builder' => function($repository) {
// $qb = $repository->createQueryBuilder('h')->orderBy('h.hideWhat', 'ASC');
// return $qb;
// }
// ))
// ->add('hoardHideFrom', EntityType::class, array(
// 'class' => 'OxHoardBundle:HideFrom',
// 'required' => false,
// 'query_builder' => function($repository) {
// $qb = $repository->createQueryBuilder('h')->orderBy('h.hideFrom', 'ASC');
// return $qb;
// }
// ))
->add('hoardCredit', TextType::class, array(
'required' => false
))
->add('hoardComment', TextType::class, array(
'required' => false
))
->add('hoardReference_string', TextType::class, array(
'required' => false
))
->add('coinPeriod', EntityType::class, array(
'class' => 'OxHoardBundle:Period',
'required' => false,
'multiple' => true,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('p');
$qb->orderBy('p.sortValue', 'DESC')
->addOrderBy('p.period', 'ASC');
return $qb;
}
))
->add('coinPersons', EntityType::class, array(
'class' => 'OxHoardBundle:Person',
'required' => false,
'multiple' => true,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('p');
$qb->orderBy('p.person', 'ASC');
return $qb;
}
))
->add('coinReigns', EntityType::class, array(
'class' => 'OxHoardBundle:Reign',
'required' => false,
'multiple' => true,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('r');
$qb->orderBy('r.startDate, r.endDate', 'ASC');
return $qb;
}
))
->add('coinDenominations', EntityType::class, array(
'class' => 'OxHoardBundle:Denomination',
'required' => false,
'multiple' => true,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('d');
$qb->orderBy('d.denomination', 'ASC');
return $qb;
}
))
->add('coinMaterials', ChoiceType::class, array(
'choices' => array("Gold" => "23", "Silver" => "22,31", "Bronze" => "7,49,53"),
'required' => false
))
->add('coinMints', EntityType::class, array(
'class' => 'OxHoardBundle:Mint',
'required' => false,
'multiple' => true,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('m');
$qb->orderBy('m.mint', 'ASC');
return $qb;
}
))
// ->add('coinIssue', NumberType::class, array(
// 'required' => false,
// 'attr' => array (
// 'float' => false, //force it to use number type in our field template
// 'step' => 1,
// 'min' => 0
// )
// ))
->add('coinAspects', EntityType::class, array(
'class' => 'OxHoardBundle:Aspect',
'required' => false,
'multiple' => true,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('a');
$qb->orderBy('a.sortValue', 'DESC')
->addOrderBy('a.aspect', 'ASC');
return $qb;
}
))
->add('coinCondition', EntityType::class, array(
'class' => 'OxHoardBundle:Condition',
'required' => false,
'multiple' => true,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('c');
$qb->orderBy('c.sortValue', 'DESC')
->addOrderBy('c.condition', 'ASC');
return $qb;
}
))
->add('coinReference', EntityType::class, array(
'class' => 'OxHoardBundle:Reference',
'required' => false,
'multiple' => true,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('r');
$qb->orderBy('r.sortValue', 'DESC')
->addOrderBy('r.abbreviation', 'DESC')
->addOrderBy('r.title', 'ASC');
return $qb;
}
))
->add('coinReferenceString', TextType::class, array(
'required' => false
))
->add('coinImitation', CheckboxType::class, array(
'required' => false
))
->add('coinHasImage', CheckboxType::class, array(
'required' => false
))
->add('coinToCheck', CheckboxType::class, array(
'required' => false
))
// ->add('hoardContainerString', TextType::class, array(
// 'required' => false
// ))
// ->add('hoardContainerComment', TextType::class, array(
// 'required' => false
// ))
->add('hoardHasContainer', CheckboxType::class, array(
'required' => false
))
->add('hoardContainerMaterials', EntityType::class, array(
'class' => 'OxHoardBundle:Material',
'multiple' => true,
'required' => false,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('m');
$qb->orderBy('m.sortValue', 'DESC')
->addOrderBy('m.material', 'ASC');
return $qb;
}
))
->add('hoardContainerHasImage', CheckboxType::class, array(
'required' => false
))
->add('hoardContainerForms', EntityType::class, array(
'class' => 'OxHoardBundle:ContainerForm',
'multiple' => true,
'required' => false,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('h');
$qb->orderBy('h.sortValue', 'DESC')
->addOrderBy('h.containerForm', 'ASC');
return $qb;
}
))
// ->add('hoardObjectComment', TextType::class, array(
// 'required' => false
// ))
->add('hoardHasObject', CheckboxType::class, array(
'required' => false
))
->add('hoardHasObjectWithImage', CheckboxType::class, array(
'required' => false
))
->add('hoardObjectMaterials', EntityType::class, array(
'class' => 'OxHoardBundle:Material',
'multiple' => true,
'required' => false,
'query_builder' => function($repository) {
$qb = $repository->createQueryBuilder('m');
$qb->orderBy('m.sortValue', 'DESC')
->addOrderBy('m.material', 'ASC');
return $qb;
}
))
->add('hoardObjectType', TextType::class, array(
'required' => false
))
;
}
/**
* @param ResolverInterface $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => null
));
}
/**
* @return string
*/
public function getBlockPrefix()
{
return 'ox_hs';
}
}