/** * Constructor. * * @access public * @param string $name * @param Form $form * @since 1.0.0-alpha * @version 1.0.0-alpha */ public function __construct($name, Form &$form) { // add reCaptcha JavaScript API Router::getInstance()->getController()->addJs('https://www.google.com/recaptcha/api.js?hl=pl'); // get private and public keys $this->sPublickey = Config::get('recaptcha.publickey'); $this->sPrivatekey = Config::get('recaptcha.privatekey'); // parent construct parent::__construct($name, $form); }
/** * Constructor. * * @access public * @param string $name Form name * @param array $defaultValues * @param string $method * @throws Exception\Fatal * @throws Exception * @since 1.0.0-alpha * @version 1.0.0-alpha */ public function __construct($name, array $defaultValues = [], $method = Form::METHOD_POST) { if (preg_match('/[^a-z0-9_]/', $name) !== 0) { throw new Exception\Fatal('Name of the form can contain only small letters, numbers and an underscore characters.'); } $this->formName = $name; $this->defaultValues = $defaultValues; $this->validator = new Validator(); $this->setMethod($method); $this->setSubmitValue(__('send')); $this->setSubmitName($this->getName() . '_submit'); if (Helper\Arrays::get($this->getMethodValue(), $this->getSubmitName(), FALSE) || isset($_FILES[$this->getName()])) { $this->isFormSubmitted = TRUE; } // add javascripts $controller = Router::getInstance()->getController(); $controller->addJs('/themes/_common/js/form/form.js'); // loggin form creation Log::insert('Form "' . $name . '" has been created.'); }