class User extends \atk4\data\Model
{
function init() {
parent::init();
$this->addField('name');
$this->addField('email');
}
}
Last active
October 5, 2017 01:29
-
-
Save romaninsh/8ab200b86f2c0479245b97de20ecdda5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$form = $app->add(['Form', 'segment']); | |
$form->setModel(new User($db), ['email', 'password']); | |
$form->addField('is_accept_terms', null, ['type'=>'boolean']); | |
$form->submitButton->set('Register'); | |
$form->onSubmit(function ($form) { | |
if (!$form->model['is_accept_terms']) { | |
return $form->error('is_accept_terms', 'Please accept terms'); | |
} | |
$form->model->save(); | |
return $form->success('Thank you'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment