Example #1
0
 /**
  * {@inheritDoc}
  */
 public function getForm()
 {
     $currentStep = $this->getCurrentStep();
     if (!$currentStep) {
         return;
     }
     if (null === $this->form) {
         $this->form = $this->formFactory->create();
         $this->form->setAttribute('action', sprintf('?%s=%s', $this->getOptions()->getTokenParamName(), $this->getUniqueId()));
         if (!$this->getSteps()->getPrevious($currentStep)) {
             $this->form->remove('previous');
         }
         if (!$this->getSteps()->getNext($currentStep)) {
             $this->form->remove('next');
         } else {
             $this->form->remove('valid');
         }
     }
     $stepForm = $currentStep->getForm();
     if ($stepForm instanceof Form) {
         if ($this->form->has(self::STEP_FORM_NAME)) {
             $this->form->remove(self::STEP_FORM_NAME);
         }
         $stepForm->setName(self::STEP_FORM_NAME);
         $stepForm->populateValues($currentStep->getData());
         $this->form->add($stepForm);
     }
     return $this->form;
 }
Example #2
0
 /**
  * @param Entity\Note $note
  * @param string $url
  * @param string $action
  * @param array $members
  * @return \Zend\Form\Form
  */
 public function getNoteForm(Entity\Note $note, $url = '', $action = 'add', $members = null)
 {
     if (is_null($this->noteForm)) {
         $builder = new AnnotationBuilder($this->getEntityManager());
         $this->noteForm = $builder->createForm($note);
         $this->noteForm->setAttribute('action', $url);
         $this->noteForm->setAttribute('id', 'noteForm');
         $this->noteForm->setHydrator(new DoctrineObject($this->getEntityManager(), 'Secretary\\Entity\\Note'));
         $this->noteForm->bind($note);
         if ($action == 'edit' && $note->getPrivate() === false) {
             $this->noteForm->remove('private');
             $group = $note->getGroup();
             $membersString = $this->getMembersString(array_keys($members));
             $this->noteForm->get('groupHidden')->setValue($group->getId());
             $this->noteForm->get('members')->setValue($membersString);
             $this->noteForm->getInputFilter()->remove('__initializer__');
             $this->noteForm->getInputFilter()->remove('__cloner__');
             $this->noteForm->getInputFilter()->remove('__isInitialized__');
             $this->noteForm->getInputFilter()->remove('lazyPropertiesDefaults');
         } else {
             $this->noteForm->get('private')->setAttribute('required', false);
             $this->noteForm->getInputFilter()->get('private')->setRequired(false);
         }
     }
     return $this->noteForm;
 }
Example #3
0
 /**
  * @param \Zend\Form\Form $form
  */
 protected function fixUserForm(Form &$form, $userId = null)
 {
     $auth = $this->getAuthenticationService();
     $groupId = $form->get('groupId');
     $groups = $groupId->getValueOptions();
     if (empty($groups) || $auth->getIdentity()->id == $userId) {
         $form->remove('groupId');
     }
 }
Example #4
0
 public function testAddRemove()
 {
     $form = clone $this->form;
     $this->assertEquals($form, $this->form);
     $file = new Element\File('file_resource');
     $this->form->add($file);
     $this->assertTrue($this->form->has('file_resource'));
     $this->assertNotEquals($form, $this->form);
     $this->form->remove('file_resource');
     $this->assertEquals($form, $this->form);
 }
 /**
  * Override Form remove function to perform additional operations
  * @param string $element
  */
 public function remove($element)
 {
     unset($this->rawElements[$element]);
     return parent::remove($element);
 }
Example #6
0
 /**
  * {@inheritDoc}
  */
 public function remove($elementOrFieldset)
 {
     if (!parent::has($elementOrFieldset)) {
         if ($elementOrFieldset === 'captcha') {
             $elementOrFieldset = $this->getCaptchaElementName();
         } elseif ($elementOrFieldset === 'csrf') {
             $elementOrFieldset = $this->getCsrfElementName();
         }
     }
     return parent::remove($elementOrFieldset);
 }
 /**
  *
  * @param type $elementName
  * @throws Exception
  */
 public function removeFormElement($elementName)
 {
     if (!$this->isLoadCrudSettings()) {
         return false;
     }
     if (!$this->frmMainCrud instanceof \Zend\Form\Form) {
         throw new Exception('You must define a Form object', $code, $previous);
     }
     if (!$priority) {
         $priority = $this->frmMainCrud->get($elementName)->getOption('priority');
     }
     $this->frmMainCrud->remove($elementName);
     return true;
 }
 public function addSubmitButton(Form $subForm)
 {
     $subForm->remove("btnSalvar");
     $subForm->add(['type' => 'Button', 'name' => 'btnSalvar', 'attributes' => ['class' => 'btn btn-default', 'type' => 'button'], 'options' => ['label' => 'Salvar e Continuar']]);
     return $this;
 }