/** * @param Form $form */ public function configure(Form $form) { $form->addGroup('Person'); $form->addSelect('type', 'Person', PersonEntity::getTypes()); $form->addText('name', 'Name'); $form->addFileEntityInput('logo', 'Logo'); $form->addManyToMany('users', 'Users'); $form->addTextArea('description', 'Description'); $form->addGroup('Address'); $form->addText('street', 'Street'); $form->addText('number', 'Number'); $form->addText('city', 'City'); $form->addText('zip', 'ZIP'); $form->addGroup('Contacts'); $form->addText('email', 'Email')->addCondition($form::FILLED)->addRule($form::EMAIL); $form->addText('phone', 'Phone'); $form->addText('fax', 'Fax'); $form->addText('website', 'Website')->addCondition($form::FILLED)->addRule($form::URL); $form->addGroup('Billing information'); $form->addText('identificationNumber', 'IN'); $form->addText('taxIdentificationNumber', 'TIN'); $form->addText('registration', 'Registration'); $form->addCheckbox('taxpayer', 'Taxpayer'); $form->addFileEntityInput('signature', 'Signature'); $form->addSaveButton('Save'); }
public function invoke() { $translator = $this->translator; $admin = new AdminGrid($this->personRepository); $table = $admin->getTable(); $table->setTranslator($this->translator); $table->addColumnText('name', 'Name')->getCellPrototype()->style[] = 'width: 70%;'; $table->addColumnText('type', 'Person')->setCustomRender(function (PersonEntity $personEntity) use($translator) { $types = PersonEntity::getTypes(); return $translator->translate($types[$personEntity->getType()]); })->getCellPrototype()->style[] = 'width: 30%;'; $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax'; $form = $admin->createForm($this->personFormFactory, 'Payment', NULL, \CmsModule\Components\Table\Form::TYPE_FULL); $admin->connectFormWithAction($form, $table->getAction('edit'), $admin::MODE_PLACE); // Toolbar $toolbar = $admin->getNavbar(); $toolbar->addSection('new', 'Create', 'file'); $admin->connectFormWithNavbar($form, $toolbar->getSection('new'), $admin::MODE_PLACE); $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax'; $admin->connectActionAsDelete($table->getAction('delete')); return $admin; }
/** * @param $name * @return PersonEntity */ private function getPersonByName($name) { if (($entity = $this->personRepository->findOneBy(array('name' => $name))) === NULL) { $entity = new PersonEntity(); $entity->setName($name); $this->personRepository->save($entity); } return $entity; }