public function __construct($name = 'form', $externalForm = false) { $this->name = $name; $this->externalForm = $externalForm; if (!$externalForm) { $this->add(HiddenField::name($this->name . "_is_submitted")->value(1)->required(true)); } }
function _createAddCommentForm($content_id, $content_type) { $form = new Form(); $form->action = "/comment/add"; $form->submitText = "Add Comment"; $form->add(HiddenField::name('content_id')->value($content_id)); $form->add(HiddenField::name('content_type')->value($content_type)); $form->add(TextareaField::name('comment')->required(true)->width('50%')->rows(3)); return $form; }
public function __construct($name = 'form', $externalForm = false) { $this->name = $name; $this->externalForm = $externalForm; if (!$externalForm) { // Submission token in case of multiple forms $this->add(HiddenField::name($this->name . "_is_submitted")->value(1)->required(true)); // CSRF token $this->add(CSRFTokenField::name("CSRFToken")->value($_SESSION['CSRFToken'])->required(true)); } }
public function _createLoginForm() { $form = new Form("login"); $form->action = "/login"; if (!$this->args('username')) { $username = ''; } else { $username = $this->args('username'); } $form->add(HiddenField::name('action')->value('login')->required(true)); $form->add(TextField::name('username')->label('Username')->value($username)->required(true)); $form->add(PasswordField::name('password')->label('Password')->required(true)); $form->add(CheckboxField::name('remember_me')->label("Remember me on this computer.")->checked(true)); $form->setSubmitText("Sign into your account"); $form->setSubmitClass("btn btn-primary btn-large"); return $form; }
/** * @return Form */ private function createFileForm() { /** @var Form $form */ $form = new Form('file', true); /** @var StorageInterface $file */ $file = Storage::newFile(); $fields = $file->getUploadFields(); foreach ($fields as $name => $value) { $form->add(HiddenField::name($name)->value($value)); } $form->add(UploadField::name("file")); $form->setSubmitText("Upload File"); $form->action = $file->getUploadURL(); return $form; }
/** * @param $token OAuthToken * @param $app OAuthConsumer * @return Form */ public function _createAuthorizationForm($token, $app) { $form = new Form(); $form->action = "/app/authorize"; $form->submitText = "Approve App"; $form->add(HiddenField::name('oauth_token')->value($this->args('oauth_token'))); $form->add(HiddenField::name('verifier')->value($token->get('verifier'))); $form->add(TextField::name('name')->label('Name')->help("A nickname for this instance of " . $app->getName() . " such as the name of the computer it's running on or the machine it's intended to control.")->required(true)->value($app->getName())); return $form; }