*/
protected $action;
+ /**
+ * `true` if form is requested via an AJAX request or processes data via an AJAX request
+ * and `false` otherwise
+ * @var boolean
+ */
+ protected $ajax;
+
/**
* data handler for this document
* @var IFormDataHandler
return $this;
}
+ /**
+ * @inheritDoc
+ */
+ public function ajax($ajax = true) {
+ $this->ajax = $ajax;
+
+ return $this;
+ }
+
/**
* @inheritDoc
*/
* @inheritDoc
*/
public function getAction() {
- if ($this->action === null) {
+ if ($this->action === null && !$this->isAjax()) {
throw new \BadMethodCallException("Action has not been set.");
}
return !empty($requestData);
}
+ /**
+ * @inheritDoc
+ */
+ public function isAjax() {
+ return $this->ajax;
+ }
+
/**
* @inheritDoc
*/
*/
public function action($action);
+ /**
+ * Sets whether this form is requested via an AJAX request or processes data via an AJAX
+ * request and returns his document.
+ *
+ * @param boolean $ajax
+ * @return static this document
+ */
+ public function ajax($ajax = true);
+
/**
* Is called once after all nodes have been added to this document.
*
*
* @return string form action
*
- * @throws \BadMethodCallException if no action has been set
+ * @throws \BadMethodCallException if no action has been set and `isAjax()` is `false`
*/
public function getAction();
*/
public function hasRequestData($index = null);
+ /**
+ * Returns `true` if this form is requested via an AJAX request or processes data via an
+ * AJAX request and `false` otherwise.
+ *
+ * By default, this method returns `false`.
+ *
+ * @return boolean
+ */
+ public function isAjax();
+
/**
* Loads the field values from the given object and returns this document.
*