/** * @param EntityManager $entityManager * @param Entity\EntityAbstract $object */ public function __construct(EntityManager $entityManager, Entity\EntityAbstract $object) { parent::__construct($object->get('underscore_entity_name')); $address = new Entity\Address(); $doctrineHydrator = new DoctrineHydrator($entityManager, 'Contact\\Entity\\Address'); $this->setHydrator($doctrineHydrator)->setObject($address); $builder = new AnnotationBuilder(); /* * Go over the different form elements and add them to the form */ foreach ($builder->createForm($object)->getElements() as $element) { /* * Go over each element to add the objectManager to the EntitySelect */ if ($element instanceof EntitySelect || $element instanceof EntityMultiCheckbox) { $element->setOptions(array('object_manager' => $entityManager)); } if ($element instanceof Radio) { $attributes = $element->getAttributes(); $valueOptionsArray = 'get' . ucfirst($attributes['array']); $element->setOptions(array('value_options' => $object->{$valueOptionsArray}())); } //Add only when a type is provided if (array_key_exists('type', $element->getAttributes())) { $this->add($element); } } }
/** * @param EntityManager $entityManager * @param Entity\EntityAbstract $object */ public function __construct(EntityManager $entityManager, Entity\EntityAbstract $object) { parent::__construct($object->get('underscore_entity_name')); $doctrineHydrator = new DoctrineHydrator($entityManager); $this->setHydrator($doctrineHydrator)->setObject($object); $builder = new AnnotationBuilder(); /** * Go over the different form elements and add them to the form */ foreach ($builder->createForm($object)->getElements() as $element) { /** * Go over each element to add the objectManager to the EntitySelect */ if ($element instanceof EntitySelect || $element instanceof EntityMultiCheckbox) { $element->setOptions(array_merge_recursive($element->getOptions(), ['object_manager' => $entityManager])); } if ($element instanceof Radio) { $attributes = $element->getAttributes(); $valueOptionsArray = 'get' . ucfirst($attributes['array']); $element->setOptions(array_merge_recursive($element->getOptions(), ['value_options' => $object->{$valueOptionsArray}()])); } //Add only when a type is provided if (array_key_exists('type', $element->getAttributes())) { $this->add($element); } } $this->add(['type' => '\\Zend\\Form\\Element\\Select', 'name' => 'organisation', 'options' => ['disable_inarray_validator' => true, "label" => _("txt-organisation"), "help-block" => _("txt-organisation-help-block")]]); $this->add(['type' => '\\Zend\\Form\\Element\\Text', 'name' => 'branch', 'options' => ["label" => _("txt-branch"), "help-block" => _("txt-branch-help-block")]]); }
/** * @param EntityManager $entityManager * @param Entity\EntityAbstract $object */ public function __construct(EntityManager $entityManager, Entity\EntityAbstract $object) { parent::__construct($object->get('underscore_entity_name')); $contactOrganisation = new Entity\ContactOrganisation(); $doctrineHydrator = new DoctrineHydrator($entityManager, 'Contact\\Entity\\ContactOrganisation'); $this->setHydrator($doctrineHydrator)->setObject($contactOrganisation); $this->add(array('type' => 'Zend\\Form\\Element\\Text', 'name' => 'organisation', 'attributes' => array('label' => _("txt-organisation")))); $this->add(array('type' => 'DoctrineORMModule\\Form\\Element\\EntitySelect', 'name' => 'country', 'options' => array('target_class' => 'General\\Entity\\Country', 'object_manager' => $entityManager), 'attributes' => array('label' => _("txt-country")))); }
/** * @param ServiceManager $serviceManager * @param EntityAbstract $object */ public function __construct(ServiceManager $serviceManager, EntityAbstract $object) { parent::__construct($object->get('underscore_entity_name')); $this->serviceManager = $serviceManager; $entityManager = $this->serviceManager->get('doctrine.entitymanager.orm_default'); $contactFieldset = new \Contact\Form\ContactFieldset($entityManager, new Entity\Contact()); $contactFieldset->setUseAsBaseFieldset(true); $this->add($contactFieldset); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-submit")]]); }
/** * @param ServiceManager $serviceManager * @param EntityAbstract $object */ public function __construct(ServiceManager $serviceManager, EntityAbstract $object) { parent::__construct($object->get('underscore_entity_name')); $this->setAttribute('method', 'post'); $this->setAttribute('action', ''); $this->serviceManager = $serviceManager; /** @var \Doctrine\ORM\EntityManager $entityManager */ $entityManager = $this->serviceManager->get('Doctrine\\ORM\\EntityManager'); $contactFieldset = new ContactFieldset($entityManager, new Entity\Contact()); $contactFieldset->setUseAsBaseFieldset(true); $this->add($contactFieldset); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'deactivate', 'attributes' => ['class' => "btn btn-danger", 'value' => _("txt-deactivate")]]); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'reactivate', 'attributes' => ['class' => "btn btn-success", 'value' => _("txt-reactivate")]]); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-submit")]]); }
/** * Class constructor */ public function __construct(ServiceManager $serviceManager, EntityAbstract $object) { parent::__construct($object->get('underscore_entity_name')); $this->serviceManager = $serviceManager; $entityManager = $this->serviceManager->get('doctrine.entitymanager.orm_default'); $objectSpecificFieldset = '\\Content\\Form\\' . ucfirst($object->get('entity_name')) . 'Fieldset'; /** * Load a specific fieldSet when present */ if (class_exists($objectSpecificFieldset)) { $objectFieldset = new $objectSpecificFieldset($entityManager, $object); } else { $objectFieldset = new ObjectFieldset($entityManager, $object); } $objectFieldset->setUseAsBaseFieldset(true); $this->add($objectFieldset); $this->setAttribute('method', 'post'); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'delete', 'attributes' => ['class' => "btn btn-danger", 'value' => _("txt-delete")]]); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-submit")]]); }
/** * @param EntityManager $entityManager * @param Entity\EntityAbstract $object */ public function __construct(EntityManager $entityManager, Entity\EntityAbstract $object) { parent::__construct($object->get('underscore_entity_name')); $contact = new Entity\Contact(); $doctrineHydrator = new DoctrineHydrator($entityManager, 'Contact\\Entity\\Contact'); $this->setHydrator($doctrineHydrator)->setObject($contact); $builder = new AnnotationBuilder(); /** * Go over the different form elements and add them to the form */ foreach ($builder->createForm($object)->getElements() as $element) { /** * Go over each element to add the objectManager to the EntitySelect */ if ($element instanceof EntitySelect || $element instanceof EntityMultiCheckbox) { $element->setOptions(array('object_manager' => $entityManager)); } //Add only when a type is provided if (array_key_exists('type', $element->getAttributes())) { $this->add($element); } } $contactPhone = new ContactPhoneFieldset($entityManager, new Entity\Phone()); $contactPhone->setObject(new Entity\Phone()); $this->add(array('type' => 'Zend\\Form\\Element\\Collection', 'name' => 'phone', 'options' => array('label' => _("txt-phone-information"), 'count' => 1, 'should_create_template' => true, 'template_placeholder' => '__placeholder__', 'allow_add' => true, 'target_element' => $contactPhone))); $contactProfileFieldset = new \Contact\Form\ContactProfileFieldset($entityManager, new Entity\Profile()); $this->add($contactProfileFieldset); $contactPhoto = new \Contact\Form\ContactPhotoFieldset($entityManager, new Entity\Photo()); $contactPhoto->setObject(new Entity\Photo()); $this->add(array('type' => 'Zend\\Form\\Element\\Collection', 'name' => 'photo', 'options' => array('label' => _("txt-profile-photo"), 'count' => 1, 'should_create_template' => true, 'template_placeholder' => '__placeholder__', 'allow_add' => false, 'target_element' => $contactPhoto))); $contactAddress = new ContactAddressFieldset($entityManager, new Entity\Address()); $contactAddress->setObject(new Entity\Address()); $this->add(array('type' => 'Zend\\Form\\Element\\Collection', 'name' => 'address', 'options' => array('label' => _("txt-address-information"), 'count' => 1, 'should_create_template' => true, 'template_placeholder' => '__placeholder__', 'allow_add' => true, 'target_element' => $contactAddress))); $contactCommunity = new ContactCommunityFieldset($entityManager, new Entity\Community()); $contactCommunity->setObject(new Entity\Community()); $this->add(array('type' => 'Zend\\Form\\Element\\Collection', 'name' => 'community', 'options' => array('label' => _("txt-community-information"), 'count' => 5, 'should_create_template' => true, 'template_placeholder' => '__placeholder__', 'allow_add' => true, 'target_element' => $contactCommunity))); $contactOrganisationFieldset = new \Contact\Form\ContactOrganisationFieldset($entityManager, new Entity\ContactOrganisation()); $this->add($contactOrganisationFieldset); }
/** * @param EntityManager $entityManager * @param Entity\EntityAbstract $object */ public function __construct(EntityManager $entityManager, Entity\EntityAbstract $object) { parent::__construct($object->get('underscore_entity_name')); $photo = new Entity\Photo(); $doctrineHydrator = new DoctrineHydrator($entityManager, 'Contact\\Entity\\Photo'); $this->setHydrator($doctrineHydrator)->setObject($photo); $builder = new AnnotationBuilder(); /** * Go over the different form elements and add them to the form */ foreach ($builder->createForm($object)->getElements() as $element) { /** * Go over each element to add the objectManager to the EntitySelect */ if ($element instanceof EntitySelect || $element instanceof EntityMultiCheckbox) { $element->setOptions(array('object_manager' => $entityManager)); } //Add only when a type is provided if (array_key_exists('type', $element->getAttributes())) { $this->add($element); } } $this->add(array('type' => '\\Zend\\Form\\Element\\File', 'name' => 'file', 'options' => array("label" => "txt-photo-file", "help-block" => _("txt-photo-requirements")))); }