Submit a form

@param \Symfony\Component\DomCrawler\Form $form
@return Response
@api
331689
public function submit(Form $form)
    {
        return $this->request($form->getUri(), $form->getMethod(), $form->getPhpValues(), $form->getPhpFiles());
    }
932849
public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->configFactory()
      ->getEditable('openy_upgrade_tool.settings')
      ->set('force_mode', $form_state->getValue('force_mode'))
      ->save();
  }
191984
public function submitModalFormAjax(array $form, FormStateInterface $form_state) {
    $response = new AjaxResponse();

    // If there are any form errors, re-display the form.
    if ($form_state->hasAnyErrors()) {
      $response->addCommand(new ReplaceCommand('#modal_openy_campaign_login_form', $form));

      return $response;
    }

    $storage = $form_state->getStorage();

    // For existed and logged in during validation members. All other cases were checked during validation.
    if ($storage['status'] === 'loggedin') {
      /** @var \Drupal\node\Entity\Node $campaign Campaign object. */
      $campaign = $storage['campaign'];

      // Get default values from settings.
      $config = $this->config('openy_campaign.general_settings');

      $msgSuccess = $config->get('successful_login');
      $modalMessage = check_markup($msgSuccess['value'], $msgSuccess['format']);
      // Get message from Campaign node.
      if (!empty($campaign->field_successful_login->value)) {
        $modalMessage = check_markup($campaign->field_successful_login->value, $campaign->field_successful_login->format);
      }

      // Login before Campaign start.
      $localeCampaignStartDate = OpenYLocaleDate::createDateFromFormat($campaign->get('field_campaign_start_date')->getString());
      if (!$localeCampaignStartDate->dateExpired()) {
        $msgNotStarted = $config->get('error_login_checkins_not_started');
        $modalMessage = check_markup($msgNotStarted['value'], $msgNotStarted['format']);
        // Get message from Campaign node.
        if (!empty($campaign->field_login_checkins_not_started->value)) {
          $modalMessage = check_markup($campaign->field_login_checkins_not_started->value, $campaign->field_login_checkins_not_started->format);
        }
      }

      $landingPageId = $form_state->getValue('landing_page_id');
      $queryParameters = [];
      if (!empty($landingPageId)) {
        $landingPage = $this->nodeStorage->load($landingPageId);
        $queryParameters = [trim($landingPage->toUrl()->toString(), "/")];
      }

      $response->addCommand(new ReplaceCommand('#modal_openy_campaign_login_form', $modalMessage));

      $response->addCommand(new InvokeCommand('#drupal-modal', 'closeDialog', $queryParameters));

      return $response;
    }

    return $response;
  }
1147882
public function submitForm(array &$form, FormStateInterface $form_state)
    {
        $node = &$form_state->getTemporaryValue('node');
        $site = $this->siteManager->getContext();
        $site->home_nid = $node->id();

        $this->siteManager->getStorage()->save($site, ['home_nid']);

        $form_state->setRedirect('node/' . $node->nid);
    }
1126822
protected function handleCreate(Request $request, Form $form, AbstractPage $page)
    {
        $form->handleRequest($request);

        if ($form->isValid() && !$request->isXmlHttpRequest()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($page);
            $em->flush();

            return $this->redirect($this->getRedirectUrl($request));
        }

        return [
            'page' => $page,
            'form' => $form->createView()
        ];
    }
969675
public function startForm(HTML_QuickForm2 $form)
    {
        $this->formId = $form->getId();
        $this->rules[$this->formId] = array();
    }
599395
public function processForm( $form, $formModel ) {

		$formSubmit = $formModel->processFormSubmit( $form );

		$this->triggerNotification( $form );

		return $formSubmit;
    }
64847
def submit_form_action(step, url):
    
    form = world.browser.find_element_by_xpath(str('//form[@action="%s"]' %
                                                   url))
    form.submit()
1154793
protected function execute($request_type, $form = array())
    {
        // Set the HTTP request type
        curl_setopt($this->client->ch, CURLOPT_CUSTOMREQUEST, $request_type);

        // If additional data is delivered, we will send it along with the API request
        if (is_array($form) && ! empty($form)) {
            curl_setopt($this->client->ch, CURLOPT_POSTFIELDS, $this->httpBuildQuery($form, '', '&'));
        }

        // Store received headers in temporary memory file, remember sent headers
        $fh_header = fopen('php://temp', 'w+');
        curl_setopt($this->client->ch, CURLOPT_WRITEHEADER, $fh_header);
        curl_setopt($this->client->ch, CURLINFO_HEADER_OUT, true);

        // Execute the request
        $response_data = curl_exec($this->client->ch);

        if (curl_errno($this->client->ch) !== 0) {
            // An error occurred
            fclose($fh_header);
            throw new Exception(curl_error($this->client->ch), curl_errno($this->client->ch));
        }

        // Grab the headers
        $sent_headers = curl_getinfo($this->client->ch, CURLINFO_HEADER_OUT);
        rewind($fh_header);
        $received_headers = stream_get_contents($fh_header);
        fclose($fh_header);

        // Retrieve the HTTP response code
        $response_code = (int) curl_getinfo($this->client->ch, CURLINFO_HTTP_CODE);

        // Return the response object.
        return new Response($response_code, $sent_headers, $received_headers, $response_data);
    }
618014
public function dispatch(FormInterface $form): UiActionEvent
    {
        /** @var \EzSystems\EzPlatformAdminUi\UI\Action\FormUiActionMapperInterface[] $mappers */
        foreach ($this->mappers as $mapper) {
            if ($mapper === $this->defaultMapper) {
                continue;
            }

            if ($mapper->supports($form)) {
                return $mapper->map($form);
            }
        }

        return $this->defaultMapper->map($form);
    }
349032
public function indexAction($form = null)
    {
        $form = $form ?: $this->createForm(BasketType::class, $this->get('sonata.basket'), [
            'validation_groups' => ['elements'],
        ]);

        // always validate the basket
        if (!$form->isSubmitted()) {
            if ($violations = $this->get('validator')->validate($form)) {
                $violationMapper = new ViolationMapper();
                foreach ($violations as $violation) {
                    $violationMapper->mapViolation($violation, $form, true);
                }
            }
        }

        $this->get('session')->set('sonata_basket_delivery_redirect', 'sonata_basket_delivery_address');

        $this->get('sonata.seo.page')->setTitle($this->get('translator')->trans('basket_index_title', [], 'SonataBasketBundle'));

        return $this->render('SonataBasketBundle:Basket:index.html.twig', [
            'basket' => $this->get('sonata.basket'),
            'form' => $form->createView(),
        ]);
    }
990732
public function save(Post $form)
    {
        $this->em->persist($form);
        $this->em->flush();

        return $form;
    }
566080
public function buildForm(array $form, FormStateInterface $form_state) {
    $form['#attributes']['class'][] = 'form--default';
    $form['group_settings'] = [
      '#type' => 'fieldset',
      '#title' => $this->t('Settings'),
    ];
    $form['group_settings']['group_type'] = $this->getGroupTypeElement();
    $form['actions']['submit'] = [
      '#prefix' => '<div class="form-actions">',
      '#suffix' => '</div>',
      '#type' => 'submit',
      '#value' => $this->t('Continue'),
      '#button_type' => 'primary',
    ];

    $form['#cache']['contexts'][] = 'user';

    return $form;
  }
747737
function submit(form_id) {
        var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
        var method = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'POST';
        var headers = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : { 'X-Requested-With': 'XMLHttpRequest' };

        this._checkInit(form_id);
        var request = new XMLHttpRequest();
        if (url === null) {
            if (document.forms[form_id].hasAttribute('action')) {
                url = document.forms[form_id].getAttribute('action');
            } else {
                //throw new Error('Form.submit() is missing 2nd URL argument');
                url = '';
            }
        }
        request.open(method, url);
        var p = new Promise(function (success, fail) {
            request.onload = function () {
                if (request.status === 200) {
                    success(request.responseText);
                } else {
                    fail(request);
                }
            };
        });
        for (var header in headers) {
            request.setRequestHeader(header, headers[header]);
        }
        this._collection[form_id].set('categories', [2, 3]);
        request.send(this.getFormDataObject(form_id));
        return p;
    }
847212
public function success(Form $form) : void
    {
        if ($this->presenter->isAjax())
        {
            $values = $form->getValues();

            try
            {
                $redirect = NULL;
                $page = $this->pageRepository->findOneById($values->pageId);

                if ($this->redirectId)
                {
                    $redirect = $this->onPageRepository->findOneRedirectById($this->redirectId);
                }

                $this->onPageManager->saveRedirect($redirect, $page, $values->oldUrl);

                $form->reset();

                $this->presenter->notificationAjax(
                    'URL přesměrována',
                    'URL byla úspěšně přesměrována.',
                    'success',
                    FALSE
                );

                $this->onSave();
            }
            catch (DatabaseException $exception)
            {
                $this->presenter->notificationAjax(
                    'Chyba',
                    $exception->getMessage(),
                    'error'
                );
            }
        }
    }
572586
public function renderForm(Form $form)
	{
		foreach ($form as $element)
		{
			$this->render($element);
		}

		$tableRender = new SimpleTable();
		$tableContent = $tableRender->renderTable($this->table);

		return Html::tag('form', $form->getAttributes(), $tableContent);
	}
176682
public function submitAction()
    {
        $localeManager = $this->container->get('claroline.common.locale_manager');
        $availableLocales = $localeManager->getImplementedLocales();
        $activatedLocales = $localeManager->retrieveAvailableLocales();
        $form = $this->createForm(new InternationalizationType($activatedLocales, $availableLocales));
        $form->handleRequest($this->get('request'));

        if ($form->isValid()) {
            $data = $form->get('locales')->getData();
            $this->container->get('claroline.config.platform_config_handler')->setParameter('locales', $data);

            return new RedirectResponse($this->get('router')->generate('claro_admin_parameters_index'));
        }

       return $this->render(
           'ClarolineCoreBundle:Administration:Internationalization\form.html.twig',
           array('form' => $form->createView(), 'product' => $product)
       );
    }