/** * Constructor * */ public function __construct() { $this->currentYear = date("Y"); parent::__construct([], ['payment' => ['type' => 'hidden', 'value' => 10], 'name' => ['type' => 'text', 'label' => 'Name on credit card:', 'required' => true, 'autofocus' => true, 'validation' => array('not_empty')], 'address' => ['type' => 'text', 'label' => 'Address', 'required' => true, 'validation' => array('not_empty')], 'zip' => ['type' => 'text', 'label' => 'Zip code', 'required' => true, 'validation' => array('not_empty')], 'city' => ['type' => 'text', 'label' => 'City', 'required' => true, 'validation' => array('not_empty')], 'country' => ['type' => 'select', 'label' => 'Country', 'options' => array('default' => 'Select country', 'dk' => 'Denmark', 'fi' => 'Finland', 'no' => 'Norway', 'se' => 'Sweden'), 'validation' => array('not_empty', 'not_equal' => 'default')], 'cctype' => array('type' => 'select', 'label' => 'Credit card type', 'options' => array('default' => 'Select credit card type', 'visa' => 'VISA', 'mastercard' => 'MasterCard', 'eurocard' => 'Eurocard', 'amex' => 'American Express'), 'validation' => array('not_empty', 'not_equal' => 'default')), 'ccnumber' => array('type' => 'text', 'label' => 'Credit card number', 'validation' => array('not_empty', 'custom_test' => array('message' => 'Invalid credit card number, try 4408 0412 3456 7893 or 4417 1234 5678 9113', 'test' => 'isValidCCNumber'))), 'expmonth' => array('type' => 'select', 'label' => 'Expiration month:', 'options' => array('default' => 'Select credit card expiration month...', '01' => 'January', '02' => 'February', '03' => 'March', '04' => 'April', '05' => 'May', '06' => 'June', '07' => 'July', '08' => 'August', '09' => 'September', '10' => 'October', '11' => 'November', '12' => 'December'), 'validation' => array('not_empty', 'not_equal' => 'default')), 'expyear' => array('type' => 'select', 'label' => 'Expiration year:', 'options' => array('default' => 'Select credit card expiration year...', $this->currentYear => $this->currentYear, ++$this->currentYear => $this->currentYear, ++$this->currentYear => $this->currentYear, ++$this->currentYear => $this->currentYear, ++$this->currentYear => $this->currentYear, ++$this->currentYear => $this->currentYear), 'validation' => array('not_empty', 'not_equal' => 'default')), 'cvc' => array('type' => 'text', 'label' => 'CVC:', 'required' => true, 'validation' => array('not_empty', 'numeric')), 'pay' => array('type' => 'submit', 'value' => 'Perform payment', 'callback' => function ($this) { return true; })]); }
/** * Constructor * */ public function __construct($tags = array()) { if (isset($tags[0])) { foreach ($tags as $tag) { $tagoptions[$tag->id] = $tag->name; } parent::__construct([], ['subject' => ['type' => 'text', 'placeholder' => 'Rubrik', 'id' => 'inputEmail', 'class' => 'form-control', 'label' => 'Rubrik', 'required' => true, 'validation' => ['not_empty']], 'text' => ['type' => 'textarea', 'placeholder' => 'Fråga', 'id' => 'inputEmail', 'class' => 'form-control', 'label' => 'Fråga', 'required' => true, 'validation' => ['not_empty']], 'old_tags' => ['type' => 'select-multiple', 'placeholder' => 'Taggar', 'id' => 'inputEmail', 'class' => 'form-control', 'options' => $tagoptions, 'label' => 'Befintliga taggar'], 'new_tags' => ['type' => 'text', 'placeholder' => 'Tag?, ', 'id' => 'inputEmail', 'class' => 'form-control', 'label' => 'Skapa nya taggar, separera med komma-tecken'], 'submit' => ['type' => 'submit', 'class' => 'btn btn-lg btn-primary btn-block', 'value' => 'Skicka', 'callback' => function () { $old_tags = null; if (isset($_POST['old_tags'])) { $old_tags = $_POST['old_tags']; } $res = $this->di->dispatcher->forward(['controller' => 'questions', 'action' => 'add', 'params' => [$this->Value('subject'), $this->Value('text'), $old_tags, $this->Value('new_tags')]]); $this->saveInSession = true; return $res; }]]); } else { parent::__construct([], ['subject' => ['type' => 'text', 'placeholder' => 'Rubrik', 'id' => 'inputEmail', 'class' => 'form-control', 'label' => 'Rubrik', 'required' => true, 'validation' => ['not_empty']], 'text' => ['type' => 'textarea', 'placeholder' => 'Fråga', 'id' => 'inputEmail', 'class' => 'form-control', 'label' => 'Fråga', 'required' => true, 'validation' => ['not_empty']], 'tags_new' => ['type' => 'text', 'placeholder' => 'Taggar', 'id' => 'inputEmail', 'class' => 'form-control', 'label' => 'Skapa nya taggar, separera med komma-tecken'], 'submit' => ['type' => 'submit', 'class' => 'btn btn-lg btn-primary btn-block', 'callback' => function () { $res = $this->di->dispatcher->forward(['controller' => 'questions', 'action' => 'add', 'params' => [$this->Value('subject'), $this->Value('text')]]); $this->saveInSession = true; return $res; }], 'submit-fail' => ['type' => 'submit', 'callback' => function () { $this->AddOutput("<p><i>DoSubmitFail(): Form was submitted but I failed to process/save/validate it</i></p>"); return false; }]]); } }
/** * Customise the check() method. * * @param callable $callIfSuccess handler to call if function returns true. * @param callable $callIfFail handler to call if function returns true. */ public function check($callIfSuccess = null, $callIfFail = null) { if ($this->di->request->getPost('submit-abort')) { $this->redirectTo('users/id/' . $this->userUpd->getProperties()['id']); } else { return parent::check([$this, 'callbackSuccess'], [$this, 'callbackFail']); } }
/** * Customise the check() method. * * @param callable $callIfSuccess handler to call if function returns true. * @param callable $callIfFail handler to call if function returns true. */ public function check($callIfSuccess = null, $callIfFail = null) { if ($this->di->request->getPost('submit-abort')) { $this->redirectTo('question'); } else { return parent::check([$this, 'callbackSuccess'], [$this, 'callbackFail']); } }
/** * Constructor * */ public function __construct() { parent::__construct([], ['acronym' => ['type' => 'text', 'placeholder' => 'Användarnamn', 'id' => 'inputEmail', 'class' => 'form-control', 'label' => 'Användarnamn', 'required' => true, 'validation' => ['not_empty']], 'password' => ['type' => 'password', 'placeholder' => 'Lösenord', 'id' => 'inputPassword', 'class' => 'form-control', 'label' => 'Lösenord: ', 'required' => true, 'validation' => ['not_empty']], 'pwd-repeat' => ['type' => 'password', 'placeholder' => 'Lösenord', 'id' => 'inputPassword', 'class' => 'form-control', 'label' => 'Repetera lösenord', 'required' => true, 'validation' => ['match' => 'password']], 'email' => ['type' => 'text', 'placeholder' => 'E-mail', 'id' => 'inputEmail', 'class' => 'form-control', 'required' => true, 'validation' => ['not_empty', 'email_adress']], 'submit' => ['type' => 'submit', 'class' => 'btn btn-lg btn-primary btn-block', 'value' => 'Registrera dig', 'callback' => function () { $res = $this->di->dispatcher->forward(['controller' => 'user', 'action' => 'add', 'params' => [$this->Value('acronym'), $this->Value('password'), $this->Value('email')]]); $this->saveInSession = true; return $res; }]]); }
/** * Constructor * */ public function __construct(User $user) { parent::__construct([], ['acronym' => ['type' => 'text', 'label' => 'Användarnamn', 'required' => true, 'validation' => ['not_empty'], 'value' => $user->acronym], 'text' => ['type' => 'textarea', 'label' => 'Presentation', 'value' => $user->text], 'email' => ['type' => 'text', 'required' => true, 'validation' => ['not_empty', 'email_adress'], 'value' => $user->email], 'id' => ['type' => 'hidden', 'value' => $user->id], 'submit' => ['type' => 'submit', 'value' => 'Spara ändringar', 'callback' => function () { $res = $this->di->dispatcher->forward(['controller' => 'user', 'action' => 'update', 'params' => [$this->Value('id'), $this->Value('acronym'), $this->Value('email'), $this->Value('text')]]); $this->saveInSession = true; return $res; }]]); }
/** * Constructor * */ public function __construct($answerId = null, $questionId = null) { parent::__construct([], ['text' => ['type' => 'textarea', 'placeholder' => '...', 'id' => 'inputEmail', 'class' => 'form-control', 'label' => 'Din kommentar', 'required' => true, 'validation' => ['not_empty']], 'questionId' => ['type' => 'hidden', 'value' => $questionId], 'answerId' => ['type' => 'hidden', 'value' => $answerId], 'submit' => ['type' => 'submit', 'class' => 'btn btn-lg btn-primary btn-block', 'value' => 'Skicka', 'callback' => function () { $res = $this->di->dispatcher->forward(['controller' => 'comments', 'action' => 'addComment', 'params' => [$this->Value('text'), $this->Value('answerId'), $this->Value('questionId')]]); $this->saveInSession = true; return $res; }]]); }
/** * Customise the check() method. * * @param callable $callIfSuccess handler to call if function returns true. * @param callable $callIfFail handler to call if function returns true. */ public function check($callIfSuccess = null, $callIfFail = null) { if (isset($_POST['submit-abort'])) { $this->redirectTo($this->redirect . '#comments'); } else { return parent::check([$this, 'callbackSuccess'], [$this, 'callbackFail']); } }
/** * Constructor * */ public function __construct() { parent::__construct([], ['text' => ['type' => 'textarea', 'label' => 'Ditt svar', 'required' => true, 'validation' => ['not_empty']], 'submit' => ['type' => 'submit', 'callback' => function () { $res = $this->di->dispatcher->forward(['controller' => 'answers', 'action' => 'add', 'params' => [$this->Value('text')]]); $this->saveInSession = true; return $res; }]]); }
/** * Constructor * */ public function __construct() { parent::__construct([], ['acronym' => ['type' => 'text', 'label' => 'Användarnamn', 'required' => true, 'validation' => ['not_empty']], 'password' => ['type' => 'password', 'label' => 'Lösenord', 'required' => true, 'validation' => ['not_empty']], 'submit' => ['type' => 'submit', 'value' => 'Logga in', 'callback' => function () { $res = $this->di->dispatcher->forward(['controller' => 'user', 'action' => 'login', 'params' => [true, $this->Value('acronym'), $this->Value('password')]]); $this->saveInSession = true; return $res; }]]); }
/** * Customise the check() method. * * @param callable $callIfSuccess handler to call if function returns true. * @param callable $callIfFail handler to call if function returns true. */ public function check($callIfSuccess = null, $callIfFail = null) { if ($this->di->request->getPost('submit-abort')) { $this->di->session->set('temptag', null); // clear temptag info $this->redirectTo('tag'); } else { return parent::check([$this, 'callbackSuccess'], [$this, 'callbackFail']); } }
/** * Customise the check() method. * * @param callable $callIfSuccess handler to call if function returns true. * @param callable $callIfFail handler to call if function returns true. */ public function check($callIfSuccess = null, $callIfFail = null) { if ($this->di->request->getPost('submit-abort')) { $id = $this->di->session->get('id'); $url = $this->di->url->create('users/id/' . $id); $this->redirectTo($url); } else { return parent::check([$this, 'callbackSuccess'], [$this, 'callbackFail']); } }
/** * Customise the check() method. * * @param callable $callIfSuccess handler to call if function returns true. * @param callable $callIfFail handler to call if function returns true. */ public function check($callIfSuccess = null, $callIfFail = null) { return parent::check([$this, 'callbackSuccess'], [$this, 'callbackFail']); }
/** Create all form elements and validation rules in the constructor. * */ public function __construct() { parent::__construct(); $this->AddElement(new \Mos\HTMLForm\CFormElementText('name'))->AddElement(new \Mos\HTMLForm\CFormElementText('email'))->AddElement(new \Mos\HTMLForm\CFormElementText('phone'))->AddElement(new \Mos\HTMLForm\CFormElementSubmit('submit', array('callback' => array($this, 'DoSubmit'))))->AddElement(new \Mos\HTMLForm\CFormElementSubmit('submit-fail', array('callback' => array($this, 'DoSubmitFail')))); $this->SetValidation('name', array('not_empty'))->SetValidation('email', array('not_empty', 'email_adress'))->SetValidation('phone', array('not_empty', 'numeric')); }
/** Create all form elements and validation rules in the constructor. * */ public function __construct() { parent::__construct(); $this->AddElement(new \Mos\HTMLForm\CFormElementText('name'))->AddElement(new \Mos\HTMLForm\CFormElementText('email'))->AddElement(new \Mos\HTMLForm\CFormElementText('phone'))->AddElement(new \Mos\HTMLForm\CFormElementSubmit('submit', array('callback' => array($this, 'DoSubmit')))); }
public function __construct() { parent::__construct(); }