/** * Class constructor, form's "id" and "method" attributes can only be set here * * @param string "id" attribute of <form> tag * @param string HTTP method used to submit the form * @param mixed Additional attributes (either a string or an array) * @param bool Whether to track if the form was submitted by adding * a special hidden field */ public function __construct($id, $method = 'post', $attributes = null, $trackSubmit = true) { $method = 'GET' == strtoupper($method) ? 'get' : 'post'; $trackSubmit = empty($id) ? false : $trackSubmit; $this->attributes = array_merge(self::prepareAttributes($attributes), array('method' => $method)); parent::setId(empty($id) ? null : $id); if (!isset($this->attributes['action'])) { $this->attributes['action'] = $_SERVER['PHP_SELF']; } if ($trackSubmit && isset($_REQUEST['_qf__' . $id]) || !$trackSubmit && ('get' == $method && !empty($_GET) || 'post' == $method && (!empty($_POST) || !empty($_FILES)))) { $this->addDataSource(new HTML_QuickForm2_DataSource_SuperGlobal($method, get_magic_quotes_gpc())); } if ($trackSubmit) { $this->appendChild(HTML_QuickForm2_Factory::createElement('hidden', '_qf__' . $id)); } }