setForm example

$form['#theme'] = $view->buildThemeFunctions('views_exposed_form');
    $form['#id'] = Html::cleanCssIdentifier('views_exposed_form-' . $view->storage->id() . '-' . $display['id']);
    // Labels are built too late for inline form errors to work, resulting     // in duplicated messages.     $form['#disable_inline_form_errors'] = TRUE;

    /** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginInterface $exposed_form_plugin */
    $exposed_form_plugin = $view->display_handler->getPlugin('exposed_form');
    $exposed_form_plugin->exposedFormAlter($form$form_state);

    // Save the form.     $this->exposedFormCache->setForm($view->storage->id()$view->current_display, $form);

    return $form;
  }

  /** * {@inheritdoc} */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    $view = $form_state->get('view');

    foreach (['field', 'filter'] as $type) {
      

    public function addElement($element$name = null, $options = null)
    {
        if (!$element instanceof Element) {
            $element = new Element(
                $element,
                $name,
                $options
            );
        }
        $element->setForm($this);
        $this->elements->add($element);

        return $this;
    }

    /** * @return ArrayCollection<Element>|Element[] */
    public function getElements()
    {
        return $this->elements;
    }
$this->assertFormElement($expected_form$form, 'test');
    $this->assertSame('test-form', $form['#id']);
  }

  /** * @covers ::buildForm * * @dataProvider providerTestChildAccessInheritance */
  public function testChildAccessInheritance($element$access_checks) {
    $form_arg = new TestFormWithPredefinedForm();
    $form_arg->setForm($element);

    $form_state = new FormState();

    $form = $this->formBuilder->buildForm($form_arg$form_state);

    $actual_access_structure = [];
    $expected_access_structure = [];

    // Ensure that the expected access checks are set.     foreach ($access_checks as $access_check) {
      $parents = $access_check[0];
      

    public function getClone()
    {
        $clonedForm = clone $this;

        foreach ($this->getFields() as $field) {
            $clonedField = clone $field;
            $clonedForm->fields->add($clonedField);

            // Update owning side             $clonedField->setForm($clonedForm);
        }

        return $clonedForm;
    }

    /** * @return ArrayCollection<Field> */
    public function getFields()
    {
        return $this->fields;
    }
$form = $this->getRepository()->find($id);
        if (!$form instanceof Form) {
            $this->View()->assign(['success' => false, 'message' => 'Form not found']);

            return;
        }

        $params = $this->Request()->getParams();

        $fieldModel = new Field();
        $fieldModel->fromArray($params);
        $fieldModel->setForm($form);

        $this->getManager()->persist($fieldModel);
        $this->getManager()->flush();

        $data = $this->getManager()->toArray($fieldModel);
        $this->View()->assign(['success' => true, 'data' => $data]);
    }

    public function removeFieldAction()
    {
        $id = (int) $this->Request()->getParam('id');
        
Home | Imprint | This part of the site doesn't use cookies.