function stepOne() { $widget = $this->getWidget(); $f = new Forms\Form('post'); $f->addSection('step-one', array(Forms\newBasicTextField('title', 'Title'), Forms\newDollarAmountField('goal', 'Goal')->minAmount(0.001)->maxAmount(self::maxGoal, "Sorry, at the present time " . self::maxGoal . " is the maximum allowed goal."), Forms\newDateField('ending', 'End Date')->nameForValidation("Ending Date field"), Forms\newBasicTextField('bitcoinAddress', 'Bitcoin Address'))); if ($this->isPostRequestAndFormIsValid($f)) { foreach (array('title', 'ending', 'bitcoinAddress') as $v) { $widget->{$v} = $_POST[$v]; } $widget->setGoal($_POST['goal'], $_POST['currency']); $widget->uriID = URL\titleToUrlComponent($widget->title); if (at($_POST, 'save-and-return')) { $widget->save(); return $this->redirect('/dashboard/'); } else { $this->storeWidgetInSession($widget); return $this->redirect('/widget-wiz/step-two'); } } else { return $this->renderStep('step-one.php', $widget, $f); } }
function changePassword() { $user = $this->user; $form = new F\Form('post'); $passwordField = F\newPasswordField('password', 'Password'); $confirmPassField = new PasswordConfirmField('confirm-password', 'Re-enter password'); $form->addSection('change-password', array(F\newPasswordField('current-password', 'Current Password')->required('Please authenticate by entering your current password.')->addValidation(function ($pass) use($user) { return Passwords\isValid($pass, $user->passwordEncrypted) ? array() : array("Your current password is incorrect!"); }), $passwordField->addValidation(function ($pass) { return strlen($pass) < 5 ? array('Password must be at least five (5) characters long.') : array(); }), $confirmPassField->required('Please confirm the password by entering it a second time.'))); $success = false; if ($this->isPostRequestAndFormIsValid($form)) { $hashedPass = Passwords\hash($form->getValue("password")); $user->updatePassword($hashedPass); $success = true; } return $this->render('account/change-password.php', array('form' => $form, 'success' => $success, 'newPassword' => $this->takeFromSession('newPassword'))); }