/** * @param string $name Name of the form. * @param string[optional] $action The action (URL) whereto the form will be submitted, if not provided it will be autogenerated. * @param string[optional] $method The method to use when submiting the form, default is POST. * @param string[optional] $hash The id of the anchor to append to the action-URL. * @param bool[optional] $useToken Should we automagically add a formtoken? */ public function __construct($name, $action = null, $method = 'post', $hash = null, $useToken = true) { $this->URL = Spoon::get('url'); $this->header = Spoon::get('header'); $name = (string) $name; $hash = $hash !== null ? (string) $hash : null; $useToken = (bool) $useToken; // build the action if it wasn't provided $action = $action === null ? '/' . $this->URL->getQueryString() : (string) $action; // call the real form-class parent::__construct($name, $action, $method, $useToken); // add default classes $this->setParameter('id', $name); $this->setParameter('class', 'forkForms submitWithLink'); }
/** * @param string[optional] $name Name of the form. * @param string[optional] $action The action (URL) whereto the form will be submitted, if not provided it will be autogenerated. * @param string[optional] $method The method to use when submiting the form, default is POST. * @param bool[optional] $useToken Should we automagically add a formtoken? * @param bool[optional] $useGlobalError Should we automagically show a global error? */ public function __construct($name = null, $action = null, $method = 'post', $useToken = true, $useGlobalError = true) { if (Spoon::exists('url')) { $this->URL = Spoon::get('url'); } if (Spoon::exists('header')) { $this->header = Spoon::get('header'); } $this->useGlobalError = (bool) $useGlobalError; // build a name if there wasn't one provided $name = $name === null ? SpoonFilter::toCamelCase($this->URL->getModule() . '_' . $this->URL->getAction(), '_', true) : (string) $name; // build the action if it wasn't provided $action = $action === null ? '/' . $this->URL->getQueryString() : (string) $action; // call the real form-class parent::__construct($name, $action, $method, $useToken); // add default classes $this->setParameter('id', $name); $this->setParameter('class', 'forkForms submitWithLink'); }