1. 8.2.x core/lib/Drupal/Core/Form/FormStateInterface.php
  2. 8.0.x core/lib/Drupal/Core/Form/FormStateInterface.php
  3. 8.1.x core/lib/Drupal/Core/Form/FormStateInterface.php
  4. 8.3.x core/lib/Drupal/Core/Form/FormStateInterface.php

Namespace

Drupal\Core\Form

File

core/lib/Drupal/Core/Form/FormStateInterface.php
View source
  1. <?php
  2. namespace Drupal\Core\Form;
  3. use Drupal\Core\Url;
  4. use Symfony\Component\HttpFoundation\Response;
  5. /**
  6. * Provides an interface for an object containing the current state of a form.
  7. *
  8. * This is passed to all form related code so that the caller can use it to
  9. * examine what in the form changed when the form submission process is
  10. * complete. Furthermore, it may be used to store information related to the
  11. * processed data in the form, which will persist across page requests when the
  12. * 'cache' or 'rebuild' flag is set. See
  13. * \Drupal\Core\Form\FormState::$internalStorage for documentation of the
  14. * available flags.
  15. *
  16. * @see \Drupal\Core\Form\FormBuilderInterface
  17. * @see \Drupal\Core\Form\FormValidatorInterface
  18. * @see \Drupal\Core\Form\FormSubmitterInterface
  19. * @ingroup form_api
  20. */
  21. interface FormStateInterface {
  22. /**
  23. * Returns a reference to the complete form array.
  24. *
  25. * @return array
  26. * The complete form array.
  27. */
  28. public function &getCompleteForm();
  29. /**
  30. * Stores the complete form array.
  31. *
  32. * @param array $complete_form
  33. * The complete form array.
  34. *
  35. * @return $this
  36. */
  37. public function setCompleteForm(array &$complete_form);
  38. /**
  39. * Ensures an include file is loaded whenever the form is processed.
  40. *
  41. * Example:
  42. * @code
  43. * // Load node.admin.inc from Node module.
  44. * $form_state->loadInclude('node', 'inc', 'node.admin');
  45. * @endcode
  46. *
  47. * Use this function instead of module_load_include() from inside a form
  48. * constructor or any form processing logic as it ensures that the include file
  49. * is loaded whenever the form is processed. In contrast to using
  50. * module_load_include() directly, this method makes sure the include file is
  51. * correctly loaded also if the form is cached.
  52. *
  53. * @param string $module
  54. * The module to which the include file belongs.
  55. * @param string $type
  56. * The include file's type (file extension).
  57. * @param string|null $name
  58. * (optional) The base file name (without the $type extension). If omitted,
  59. * $module is used; i.e., resulting in "$module.$type" by default.
  60. *
  61. * @return string|false
  62. * The filepath of the loaded include file, or FALSE if the include file was
  63. * not found or has been loaded already.
  64. *
  65. * @see module_load_include()
  66. */
  67. public function loadInclude($module, $type, $name = NULL);
  68. /**
  69. * Returns an array representation of the cacheable portion of the form state.
  70. *
  71. * @return array
  72. * The cacheable portion of the form state.
  73. */
  74. public function getCacheableArray();
  75. /**
  76. * Sets the value of the form state.
  77. *
  78. * @param array $form_state_additions
  79. * An array of values to add to the form state.
  80. *
  81. * @return $this
  82. */
  83. public function setFormState(array $form_state_additions);
  84. /**
  85. * Sets a response for this form.
  86. *
  87. * If a response is set, it will be used during processing and returned
  88. * directly. The form will not be rebuilt or redirected.
  89. *
  90. * @param \Symfony\Component\HttpFoundation\Response $response
  91. * The response to return.
  92. *
  93. * @return $this
  94. */
  95. public function setResponse(Response $response);
  96. /**
  97. * Gets a response for this form.
  98. *
  99. * If a response is set, it will be used during processing and returned
  100. * directly. The form will not be rebuilt or redirected.
  101. *
  102. * @return \Symfony\Component\HttpFoundation\Response|null
  103. * The response to return, or NULL.
  104. */
  105. public function getResponse();
  106. /**
  107. * Sets the redirect for the form.
  108. *
  109. * @param string $route_name
  110. * The name of the route
  111. * @param array $route_parameters
  112. * (optional) An associative array of parameter names and values.
  113. * @param array $options
  114. * (optional) An associative array of additional options. See
  115. * \Drupal\Core\Url for the available keys.
  116. *
  117. * @return $this
  118. *
  119. * @see \Drupal\Core\Form\FormSubmitterInterface::redirectForm()
  120. */
  121. public function setRedirect($route_name, array $route_parameters = array(), array $options = array());
  122. /**
  123. * Sets the redirect URL for the form.
  124. *
  125. * @param \Drupal\Core\Url $url
  126. * The URL to redirect to.
  127. *
  128. * @return $this
  129. *
  130. * @see \Drupal\Core\Form\FormSubmitterInterface::redirectForm()
  131. */
  132. public function setRedirectUrl(Url $url);
  133. /**
  134. * Gets the value to use for redirecting after the form has been executed.
  135. *
  136. * @see \Drupal\Core\Form\FormSubmitterInterface::redirectForm()
  137. *
  138. * @return mixed
  139. * The value will be one of the following:
  140. * - A fully prepared \Symfony\Component\HttpFoundation\RedirectResponse.
  141. * - An instance of \Drupal\Core\Url to use for the redirect.
  142. * - NULL, to signify that no redirect was specified and that the current
  143. * path should be used for the redirect.
  144. * - FALSE, to signify that no redirect should take place.
  145. */
  146. public function getRedirect();
  147. /**
  148. * Sets the entire set of arbitrary data.
  149. *
  150. * @param array $storage
  151. * The entire set of arbitrary data to store for this form.
  152. *
  153. * @return $this
  154. */
  155. public function setStorage(array $storage);
  156. /**
  157. * Returns the entire set of arbitrary data.
  158. *
  159. * @return array
  160. * The entire set of arbitrary data to store for this form.
  161. */
  162. public function &getStorage();
  163. /**
  164. * Gets any arbitrary property.
  165. *
  166. * @param string|array $property
  167. * Properties are often stored as multi-dimensional associative arrays. If
  168. * $property is a string, it will return $storage[$property]. If $property
  169. * is an array, each element of the array will be used as a nested key. If
  170. * $property = ['foo', 'bar'] it will return $storage['foo']['bar'].
  171. *
  172. * @return mixed
  173. * A reference to the value for that property, or NULL if the property does
  174. * not exist.
  175. */
  176. public function &get($property);
  177. /**
  178. * Sets a value to an arbitrary property.
  179. *
  180. * @param string|array $property
  181. * Properties are often stored as multi-dimensional associative arrays. If
  182. * $property is a string, it will use $storage[$property] = $value. If
  183. * $property is an array, each element of the array will be used as a nested
  184. * key. If $property = ['foo', 'bar'] it will use
  185. * $storage['foo']['bar'] = $value.
  186. * @param mixed $value
  187. * The value to set.
  188. *
  189. * @return $this
  190. */
  191. public function set($property, $value);
  192. /**
  193. * Determines if an arbitrary property is present.
  194. *
  195. * @param string $property
  196. * Properties are often stored as multi-dimensional associative arrays. If
  197. * $property is a string, it will return isset($storage[$property]). If
  198. * $property is an array, each element of the array will be used as a nested
  199. * key. If $property = ['foo', 'bar'] it will return
  200. * isset($storage['foo']['bar']).
  201. */
  202. public function has($property);
  203. /**
  204. * Sets the build info for the form.
  205. *
  206. * @param array $build_info
  207. * An array of build info.
  208. *
  209. * @return $this
  210. *
  211. * @see \Drupal\Core\Form\FormState::$build_info
  212. */
  213. public function setBuildInfo(array $build_info);
  214. /**
  215. * Returns the build info for the form.
  216. *
  217. * @return array
  218. * An array of build info.
  219. *
  220. * @see \Drupal\Core\Form\FormState::$build_info
  221. */
  222. public function getBuildInfo();
  223. /**
  224. * Adds a value to the build info.
  225. *
  226. * @param string $property
  227. * The property to use for the value.
  228. * @param mixed $value
  229. * The value to set.
  230. *
  231. * @return $this
  232. */
  233. public function addBuildInfo($property, $value);
  234. /**
  235. * Returns the form values as they were submitted by the user.
  236. *
  237. * These are raw and unvalidated, so should not be used without a thorough
  238. * understanding of security implications. In almost all cases, code should
  239. * use self::getValues() and self::getValue() exclusively.
  240. *
  241. * @return array
  242. * An associative array of values submitted to the form.
  243. */
  244. public function &getUserInput();
  245. /**
  246. * Sets the form values as though they were submitted by a user.
  247. *
  248. * @param array $user_input
  249. * An associative array of raw and unvalidated values.
  250. *
  251. * @return $this
  252. */
  253. public function setUserInput(array $user_input);
  254. /**
  255. * Returns the submitted and sanitized form values.
  256. *
  257. * @return array
  258. * An associative array of values submitted to the form.
  259. */
  260. public function &getValues();
  261. /**
  262. * Returns the submitted form value for a specific key.
  263. *
  264. * @param string|array $key
  265. * Values are stored as a multi-dimensional associative array. If $key is a
  266. * string, it will return $values[$key]. If $key is an array, each element
  267. * of the array will be used as a nested key. If $key = array('foo', 'bar')
  268. * it will return $values['foo']['bar'].
  269. * @param mixed $default
  270. * (optional) The default value if the specified key does not exist.
  271. *
  272. * @return mixed
  273. * The value for the given key, or NULL.
  274. */
  275. public function &getValue($key, $default = NULL);
  276. /**
  277. * Sets the submitted form values.
  278. *
  279. * This should be avoided, since these values have been validated already. Use
  280. * self::setUserInput() instead.
  281. *
  282. * @param array $values
  283. * The multi-dimensional associative array of form values.
  284. *
  285. * @return $this
  286. */
  287. public function setValues(array $values);
  288. /**
  289. * Sets the submitted form value for a specific key.
  290. *
  291. * @param string|array $key
  292. * Values are stored as a multi-dimensional associative array. If $key is a
  293. * string, it will use $values[$key] = $value. If $key is an array, each
  294. * element of the array will be used as a nested key. If
  295. * $key = array('foo', 'bar') it will use $values['foo']['bar'] = $value.
  296. * @param mixed $value
  297. * The value to set.
  298. *
  299. * @return $this
  300. */
  301. public function setValue($key, $value);
  302. /**
  303. * Removes a specific key from the submitted form values.
  304. *
  305. * @param string|array $key
  306. * Values are stored as a multi-dimensional associative array. If $key is a
  307. * string, it will use unset($values[$key]). If $key is an array, each
  308. * element of the array will be used as a nested key. If
  309. * $key = array('foo', 'bar') it will use unset($values['foo']['bar']).
  310. *
  311. * @return $this
  312. */
  313. public function unsetValue($key);
  314. /**
  315. * Determines if a specific key is present in the submitted form values.
  316. *
  317. * @param string|array $key
  318. * Values are stored as a multi-dimensional associative array. If $key is a
  319. * string, it will return isset($values[$key]). If $key is an array, each
  320. * element of the array will be used as a nested key. If
  321. * $key = array('foo', 'bar') it will return isset($values['foo']['bar']).
  322. *
  323. * @return bool
  324. * TRUE if the $key is set, FALSE otherwise.
  325. */
  326. public function hasValue($key);
  327. /**
  328. * Determines if a specific key has a value in the submitted form values.
  329. *
  330. * @param string|array $key
  331. * Values are stored as a multi-dimensional associative array. If $key is a
  332. * string, it will return empty($values[$key]). If $key is an array, each
  333. * element of the array will be used as a nested key. If
  334. * $key = array('foo', 'bar') it will return empty($values['foo']['bar']).
  335. *
  336. * @return bool
  337. * TRUE if the $key has no value, FALSE otherwise.
  338. */
  339. public function isValueEmpty($key);
  340. /**
  341. * Changes submitted form values during form validation.
  342. *
  343. * Use this function to change the submitted value of a form element in a form
  344. * validation function, so that the changed value persists in $form_state
  345. * through to the submission handlers.
  346. *
  347. * Note that form validation functions are specified in the '#validate'
  348. * component of the form array (the value of $form['#validate'] is an array of
  349. * validation function names). If the form does not originate in your module,
  350. * you can implement hook_form_FORM_ID_alter() to add a validation function
  351. * to $form['#validate'].
  352. *
  353. * @param array $element
  354. * The form element that should have its value updated; in most cases you
  355. * can just pass in the element from the $form array, although the only
  356. * component that is actually used is '#parents'. If constructing yourself,
  357. * set $element['#parents'] to be an array giving the path through the form
  358. * array's keys to the element whose value you want to update. For instance,
  359. * if you want to update the value of $form['elem1']['elem2'], which should
  360. * be stored in $form_state->getValue(array('elem1', 'elem2')), you would
  361. * set $element['#parents'] = array('elem1','elem2').
  362. * @param mixed $value
  363. * The new value for the form element.
  364. *
  365. * @return $this
  366. */
  367. public function setValueForElement(array $element, $value);
  368. /**
  369. * Determines if any forms have any errors.
  370. *
  371. * @return bool
  372. * TRUE if any form has any errors, FALSE otherwise.
  373. */
  374. public static function hasAnyErrors();
  375. /**
  376. * Files an error against a form element.
  377. *
  378. * When a validation error is detected, the validator calls this method to
  379. * indicate which element needs to be changed and provide an error message.
  380. * This causes the Form API to not execute the form submit handlers, and
  381. * instead to re-display the form to the user with the corresponding elements
  382. * rendered with an 'error' CSS class (shown as red by default).
  383. *
  384. * The standard behavior of this method can be changed if a button provides
  385. * the #limit_validation_errors property. Multistep forms not wanting to
  386. * validate the whole form can set #limit_validation_errors on buttons to
  387. * limit validation errors to only certain elements. For example, pressing the
  388. * "Previous" button in a multistep form should not fire validation errors
  389. * just because the current step has invalid values. If
  390. * #limit_validation_errors is set on a clicked button, the button must also
  391. * define a #submit property (may be set to an empty array). Any #submit
  392. * handlers will be executed even if there is invalid input, so extreme care
  393. * should be taken with respect to any actions taken by them. This is
  394. * typically not a problem with buttons like "Previous" or "Add more" that do
  395. * not invoke persistent storage of the submitted form values. Do not use the
  396. * #limit_validation_errors property on buttons that trigger saving of form
  397. * values to the database.
  398. *
  399. * The #limit_validation_errors property is a list of "sections" within
  400. * $form_state->getValues() that must contain valid values. Each "section" is
  401. * an array with the ordered set of keys needed to reach that part of
  402. * $form_state->getValues() (i.e., the #parents property of the element).
  403. *
  404. * Example 1: Allow the "Previous" button to function, regardless of whether
  405. * any user input is valid.
  406. *
  407. * @code
  408. * $form['actions']['previous'] = array(
  409. * '#type' => 'submit',
  410. * '#value' => t('Previous'),
  411. * '#limit_validation_errors' => array(), // No validation.
  412. * '#submit' => array('some_submit_function'), // #submit required.
  413. * );
  414. * @endcode
  415. *
  416. * Example 2: Require some, but not all, user input to be valid to process the
  417. * submission of a "Previous" button.
  418. *
  419. * @code
  420. * $form['actions']['previous'] = array(
  421. * '#type' => 'submit',
  422. * '#value' => t('Previous'),
  423. * '#limit_validation_errors' => array(
  424. * // Validate $form_state->getValue('step1').
  425. * array('step1'),
  426. * // Validate $form_state->getValue(array('foo', 'bar')).
  427. * array('foo', 'bar'),
  428. * ),
  429. * '#submit' => array('some_submit_function'), // #submit required.
  430. * );
  431. * @endcode
  432. *
  433. * This will require $form_state->getValue('step1') and everything within it
  434. * (for example, $form_state->getValue(array('step1', 'choice'))) to be valid,
  435. * so calls to self::setErrorByName('step1', $message) or
  436. * self::setErrorByName('step1][choice', $message) will prevent the submit
  437. * handlers from running, and result in the error message being displayed to
  438. * the user. However, calls to self::setErrorByName('step2', $message) and
  439. * self::setErrorByName('step2][groupX][choiceY', $message) will be
  440. * suppressed, resulting in the message not being displayed to the user, and
  441. * the submit handlers will run despite $form_state->getValue('step2') and
  442. * $form_state->getValue(array('step2', 'groupX', 'choiceY')) containing
  443. * invalid values. Errors for an invalid $form_state->getValue('foo') will be
  444. * suppressed, but errors flagging invalid values for
  445. * $form_state->getValue(array('foo', 'bar')) and everything within it will
  446. * be flagged and submission prevented.
  447. *
  448. * Partial form validation is implemented by suppressing errors rather than by
  449. * skipping the input processing and validation steps entirely, because some
  450. * forms have button-level submit handlers that call Drupal API functions that
  451. * assume that certain data exists within $form_state->getValues(), and while
  452. * not doing anything with that data that requires it to be valid, PHP errors
  453. * would be triggered if the input processing and validation steps were fully
  454. * skipped.
  455. *
  456. * @param string $name
  457. * The name of the form element. If the #parents property of your form
  458. * element is array('foo', 'bar', 'baz') then you may set an error on 'foo'
  459. * or 'foo][bar][baz'. Setting an error on 'foo' sets an error for every
  460. * element where the #parents array starts with 'foo'.
  461. * @param string $message
  462. * (optional) The error message to present to the user.
  463. *
  464. * @return $this
  465. */
  466. public function setErrorByName($name, $message = '');
  467. /**
  468. * Flags an element as having an error.
  469. *
  470. * @param array $element
  471. * The form element.
  472. * @param string $message
  473. * (optional) The error message to present to the user.
  474. *
  475. * @return $this
  476. */
  477. public function setError(array &$element, $message = '');
  478. /**
  479. * Clears all errors against all form elements made by self::setErrorByName().
  480. */
  481. public function clearErrors();
  482. /**
  483. * Returns an associative array of all errors.
  484. *
  485. * @return array
  486. * An array of all errors, keyed by the name of the form element.
  487. */
  488. public function getErrors();
  489. /**
  490. * Returns the error message filed against the given form element.
  491. *
  492. * Form errors higher up in the form structure override deeper errors as well
  493. * as errors on the element itself.
  494. *
  495. * @param array $element
  496. * The form element to check for errors.
  497. *
  498. * @return string|null
  499. * Either the error message for this element or NULL if there are no errors.
  500. */
  501. public function getError(array $element);
  502. /**
  503. * Sets the form to be rebuilt after processing.
  504. *
  505. * @param bool $rebuild
  506. * (optional) Whether the form should be rebuilt or not. Defaults to TRUE.
  507. *
  508. * @return $this
  509. */
  510. public function setRebuild($rebuild = TRUE);
  511. /**
  512. * Determines if the form should be rebuilt after processing.
  513. *
  514. * @return bool
  515. * TRUE if the form should be rebuilt, FALSE otherwise.
  516. */
  517. public function isRebuilding();
  518. /**
  519. * Flags the form state as having or not an invalid token.
  520. *
  521. * @param bool $invalid_token
  522. * Whether the form has an invalid token.
  523. *
  524. * @return $this
  525. */
  526. public function setInvalidToken($invalid_token);
  527. /**
  528. * Determines if the form has an invalid token.
  529. *
  530. * @return bool
  531. * TRUE if the form has an invalid token, FALSE otherwise.
  532. */
  533. public function hasInvalidToken();
  534. /**
  535. * Converts support notations for a form callback to a valid callable.
  536. *
  537. * Specifically, supports methods on the form/callback object as strings when
  538. * they start with ::, for example "::submitForm()".
  539. *
  540. * @param string|array $callback
  541. * The callback.
  542. *
  543. * @return array|string
  544. * A valid callable.
  545. */
  546. public function prepareCallback($callback);
  547. /**
  548. * Returns the form object that is responsible for building this form.
  549. *
  550. * @return \Drupal\Core\Form\FormInterface
  551. * The form object.
  552. */
  553. public function getFormObject();
  554. /**
  555. * Sets the form object that is responsible for building this form.
  556. *
  557. * @param \Drupal\Core\Form\FormInterface $form_object
  558. * The form object.
  559. *
  560. * @return $this
  561. */
  562. public function setFormObject(FormInterface $form_object);
  563. /**
  564. * Sets this form to always be processed.
  565. *
  566. * This should only be used on RESTful GET forms that do NOT write data, as
  567. * this could lead to security issues. It is useful so that searches do not
  568. * need to have a form_id in their query arguments to trigger the search.
  569. *
  570. * @param bool $always_process
  571. * TRUE if the form should always be processed, FALSE otherwise.
  572. *
  573. * @return $this
  574. */
  575. public function setAlwaysProcess($always_process = TRUE);
  576. /**
  577. * Determines if this form should always be processed.
  578. *
  579. * @return bool
  580. * TRUE if the form should always be processed, FALSE otherwise.
  581. */
  582. public function getAlwaysProcess();
  583. /**
  584. * Stores the submit and button elements for the form.
  585. *
  586. * @param array $buttons
  587. * The submit and button elements.
  588. *
  589. * @return $this
  590. */
  591. public function setButtons(array $buttons);
  592. /**
  593. * Returns the submit and button elements for the form.
  594. *
  595. * @return array
  596. * The submit and button elements.
  597. */
  598. public function getButtons();
  599. /**
  600. * Sets this form to be cached.
  601. *
  602. * @param bool $cache
  603. * TRUE if the form should be cached, FALSE otherwise.
  604. *
  605. * @return $this
  606. *
  607. * @throws \LogicException
  608. * If the current request is using an HTTP method that must not change
  609. * state (e.g., GET).
  610. */
  611. public function setCached($cache = TRUE);
  612. /**
  613. * Determines if the form should be cached.
  614. *
  615. * @return bool
  616. * TRUE if the form should be cached, FALSE otherwise.
  617. */
  618. public function isCached();
  619. /**
  620. * Prevents the form from being cached.
  621. *
  622. * @return $this
  623. */
  624. public function disableCache();
  625. /**
  626. * Sets that the form was submitted and has been processed and executed.
  627. *
  628. * @return $this
  629. */
  630. public function setExecuted();
  631. /**
  632. * Determines if the form was submitted and has been processed and executed.
  633. *
  634. * @return bool
  635. * TRUE if the form was submitted and has been processed and executed.
  636. */
  637. public function isExecuted();
  638. /**
  639. * Sets references to details elements to render them within vertical tabs.
  640. *
  641. * @param array $groups
  642. * References to details elements to render them within vertical tabs.
  643. *
  644. * @return $this
  645. */
  646. public function setGroups(array $groups);
  647. /**
  648. * Returns references to details elements to render them within vertical tabs.
  649. *
  650. * @return array
  651. */
  652. public function &getGroups();
  653. /**
  654. * Sets that this form has a file element.
  655. *
  656. * @param bool $has_file_element
  657. * Whether this form has a file element.
  658. *
  659. * @return $this
  660. */
  661. public function setHasFileElement($has_file_element = TRUE);
  662. /**
  663. * Returns whether this form has a file element.
  664. *
  665. * @return bool
  666. * Whether this form has a file element.
  667. */
  668. public function hasFileElement();
  669. /**
  670. * Sets the limited validation error sections.
  671. *
  672. * @param array|null $limit_validation_errors
  673. * The limited validation error sections.
  674. *
  675. * @return $this
  676. *
  677. * @see \Drupal\Core\Form\FormState::$limit_validation_errors
  678. */
  679. public function setLimitValidationErrors($limit_validation_errors);
  680. /**
  681. * Retrieves the limited validation error sections.
  682. *
  683. * @return array|null
  684. * The limited validation error sections.
  685. *
  686. * @see \Drupal\Core\Form\FormState::$limit_validation_errors
  687. */
  688. public function getLimitValidationErrors();
  689. /**
  690. * Sets the HTTP method to use for the form's submission.
  691. *
  692. * This is what the form's "method" attribute should be, not necessarily what
  693. * the current request's HTTP method is. For example, a form can have a
  694. * method attribute of POST, but the request that initially builds it uses
  695. * GET.
  696. *
  697. * @param string $method
  698. * Either "GET" or "POST". Other HTTP methods are not valid form submission
  699. * methods.
  700. *
  701. * @see \Drupal\Core\Form\FormState::$method
  702. * @see \Drupal\Core\Form\FormStateInterface::setRequestMethod()
  703. *
  704. * @return $this
  705. */
  706. public function setMethod($method);
  707. /**
  708. * Sets the HTTP method used by the request that is building the form.
  709. *
  710. * @param string $method
  711. * Can be any valid HTTP method, such as GET, POST, HEAD, etc.
  712. *
  713. * @return $this
  714. *
  715. * @see \Drupal\Core\Form\FormStateInterface::setMethod()
  716. */
  717. public function setRequestMethod($method);
  718. /**
  719. * Returns the HTTP form method.
  720. *
  721. * @param string
  722. * The HTTP form method.
  723. *
  724. * @return bool
  725. * TRUE if the HTTP form method matches.
  726. *
  727. * @see \Drupal\Core\Form\FormState::$method
  728. */
  729. public function isMethodType($method_type);
  730. /**
  731. * Enforces that validation is run.
  732. *
  733. * @param bool $must_validate
  734. * If TRUE, validation will always be run.
  735. *
  736. * @return $this
  737. */
  738. public function setValidationEnforced($must_validate = TRUE);
  739. /**
  740. * Checks if validation is enforced.
  741. *
  742. * @return bool
  743. * If TRUE, validation will always be run.
  744. */
  745. public function isValidationEnforced();
  746. /**
  747. * Prevents the form from redirecting.
  748. *
  749. * @param bool $no_redirect
  750. * If TRUE, the form will not redirect.
  751. *
  752. * @return $this
  753. */
  754. public function disableRedirect($no_redirect = TRUE);
  755. /**
  756. * Determines if redirecting has been prevented.
  757. *
  758. * @return bool
  759. * If TRUE, the form will not redirect.
  760. */
  761. public function isRedirectDisabled();
  762. /**
  763. * Sets that the form should process input.
  764. *
  765. * @param bool $process_input
  766. * If TRUE, the form input will be processed.
  767. *
  768. * @return $this
  769. */
  770. public function setProcessInput($process_input = TRUE);
  771. /**
  772. * Determines if the form input will be processed.
  773. *
  774. * @return bool
  775. * If TRUE, the form input will be processed.
  776. */
  777. public function isProcessingInput();
  778. /**
  779. * Sets that this form was submitted programmatically.
  780. *
  781. * @param bool $programmed
  782. * If TRUE, the form was submitted programmatically.
  783. *
  784. * @return $this
  785. */
  786. public function setProgrammed($programmed = TRUE);
  787. /**
  788. * Returns if this form was submitted programmatically.
  789. *
  790. * @return bool
  791. * If TRUE, the form was submitted programmatically.
  792. */
  793. public function isProgrammed();
  794. /**
  795. * Sets if this form submission should bypass #access.
  796. *
  797. * @param bool $programmed_bypass_access_check
  798. * If TRUE, programmatic form submissions are processed without taking
  799. * #access into account.
  800. *
  801. * @return $this
  802. *
  803. * @see \Drupal\Core\Form\FormState::$programmed_bypass_access_check
  804. */
  805. public function setProgrammedBypassAccessCheck($programmed_bypass_access_check = TRUE);
  806. /**
  807. * Determines if this form submission should bypass #access.
  808. *
  809. * @return bool
  810. *
  811. * @see \Drupal\Core\Form\FormState::$programmed_bypass_access_check
  812. */
  813. public function isBypassingProgrammedAccessChecks();
  814. /**
  815. * Sets the rebuild info.
  816. *
  817. * @param array $rebuild_info
  818. * The rebuild info.
  819. *
  820. * @return $this
  821. *
  822. * @see \Drupal\Core\Form\FormState::$rebuild_info
  823. */
  824. public function setRebuildInfo(array $rebuild_info);
  825. /**
  826. * Gets the rebuild info.
  827. *
  828. * @return array
  829. * The rebuild info.
  830. *
  831. * @see \Drupal\Core\Form\FormState::$rebuild_info
  832. */
  833. public function getRebuildInfo();
  834. /**
  835. * Adds a value to the rebuild info.
  836. *
  837. * @param string $property
  838. * The property to use for the value.
  839. * @param mixed $value
  840. * The value to set.
  841. *
  842. * @return $this
  843. */
  844. public function addRebuildInfo($property, $value);
  845. /**
  846. * Sets the submit handlers.
  847. *
  848. * @param array $submit_handlers
  849. * An array of submit handlers.
  850. *
  851. * @return $this
  852. */
  853. public function setSubmitHandlers(array $submit_handlers);
  854. /**
  855. * Gets the submit handlers.
  856. *
  857. * @return array
  858. * An array of submit handlers.
  859. */
  860. public function getSubmitHandlers();
  861. /**
  862. * Sets that the form has been submitted.
  863. *
  864. * @return $this
  865. */
  866. public function setSubmitted();
  867. /**
  868. * Determines if the form has been submitted.
  869. *
  870. * @return bool
  871. * TRUE if the form has been submitted, FALSE otherwise.
  872. */
  873. public function isSubmitted();
  874. /**
  875. * Sets temporary data.
  876. *
  877. * @param array $temporary
  878. * Temporary data accessible during the current page request only.
  879. *
  880. * @return $this
  881. */
  882. public function setTemporary(array $temporary);
  883. /**
  884. * Gets temporary data.
  885. *
  886. * @return array
  887. * Temporary data accessible during the current page request only.
  888. */
  889. public function getTemporary();
  890. /**
  891. * Gets an arbitrary value from temporary storage.
  892. *
  893. * @param string|array $key
  894. * Properties are often stored as multi-dimensional associative arrays. If
  895. * $key is a string, it will return $temporary[$key]. If $key is an array,
  896. * each element of the array will be used as a nested key. If
  897. * $key = ['foo', 'bar'] it will return $temporary['foo']['bar'].
  898. *
  899. * @return mixed
  900. * A reference to the value for that key, or NULL if the property does
  901. * not exist.
  902. */
  903. public function &getTemporaryValue($key);
  904. /**
  905. * Sets an arbitrary value in temporary storage.
  906. *
  907. * @param string|array $key
  908. * Properties are often stored as multi-dimensional associative arrays. If
  909. * $key is a string, it will use $temporary[$key] = $value. If $key is an
  910. * array, each element of the array will be used as a nested key. If
  911. * $key = ['foo', 'bar'] it will use $temporary['foo']['bar'] = $value.
  912. * @param mixed $value
  913. * The value to set.
  914. *
  915. * @return $this
  916. */
  917. public function setTemporaryValue($key, $value);
  918. /**
  919. * Determines if a temporary value is present.
  920. *
  921. * @param string $key
  922. * Properties are often stored as multi-dimensional associative arrays. If
  923. * $key is a string, it will return isset($temporary[$key]). If $key is an
  924. * array, each element of the array will be used as a nested key. If
  925. * $key = ['foo', 'bar'] it will return isset($temporary['foo']['bar']).
  926. */
  927. public function hasTemporaryValue($key);
  928. /**
  929. * Sets the form element that triggered submission.
  930. *
  931. * @param array|null $triggering_element
  932. * The form element that triggered submission, of NULL if there is none.
  933. *
  934. * @return $this
  935. */
  936. public function setTriggeringElement($triggering_element);
  937. /**
  938. * Gets the form element that triggered submission.
  939. *
  940. * @return array|null
  941. * The form element that triggered submission, of NULL if there is none.
  942. */
  943. public function &getTriggeringElement();
  944. /**
  945. * Sets the validate handlers.
  946. *
  947. * @param array $validate_handlers
  948. * An array of validate handlers.
  949. *
  950. * @return $this
  951. */
  952. public function setValidateHandlers(array $validate_handlers);
  953. /**
  954. * Gets the validate handlers.
  955. *
  956. * @return array
  957. * An array of validate handlers.
  958. */
  959. public function getValidateHandlers();
  960. /**
  961. * Sets that validation has been completed.
  962. *
  963. * @param bool $validation_complete
  964. * TRUE if validation is complete, FALSE otherwise.
  965. *
  966. * @return $this
  967. */
  968. public function setValidationComplete($validation_complete = TRUE);
  969. /**
  970. * Determines if validation has been completed.
  971. *
  972. * @return bool
  973. * TRUE if validation is complete, FALSE otherwise.
  974. */
  975. public function isValidationComplete();
  976. /**
  977. * Gets the keys of the form values that will be cleaned.
  978. *
  979. * @return array
  980. * An array of form value keys to be cleaned.
  981. */
  982. public function getCleanValueKeys();
  983. /**
  984. * Sets the keys of the form values that will be cleaned.
  985. *
  986. * @param array $keys
  987. * An array of form value keys to be cleaned.
  988. *
  989. * @return $this
  990. */
  991. public function setCleanValueKeys(array $keys);
  992. /**
  993. * Adds a key to the array of form values that will be cleaned.
  994. *
  995. * @param string $key
  996. * The form value key to be cleaned.
  997. *
  998. * @return $this
  999. */
  1000. public function addCleanValueKey($key);
  1001. /**
  1002. * Removes internal Form API elements and buttons from submitted form values.
  1003. *
  1004. * This function can be used when a module wants to store all submitted form
  1005. * values, for example, by serializing them into a single database column. In
  1006. * such cases, all internal Form API values and all form button elements
  1007. * should not be contained, and this function allows their removal before the
  1008. * module proceeds to storage. Next to button elements, the following internal
  1009. * values are removed by default.
  1010. * - form_id
  1011. * - form_token
  1012. * - form_build_id
  1013. * - op
  1014. *
  1015. * @return $this
  1016. */
  1017. public function cleanValues();
  1018. }

Interfaces

Namesort descending Description
FormStateInterface Provides an interface for an object containing the current state of a form.