本文整理汇总了PHP中Forms::addInput方法的典型用法代码示例。如果您正苦于以下问题:PHP Forms::addInput方法的具体用法?PHP Forms::addInput怎么用?PHP Forms::addInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Forms
的用法示例。
在下文中一共展示了Forms::addInput方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionEdit
/**
* Edit comment
* @return void
*/
public function actionEdit($id)
{
// authorization
$this->checkAuth();
$data = array();
$data['page_title'] = 'Edit comment';
$comment = $this->db->comment[$id];
if (!$comment) {
$this->notFound();
}
// Form
$form = new Forms('commentEdit');
$form->successMessage = 'Comment was saved.';
$form->errorMessage = 'Error while saving comment. Try it later.';
$form->addInput('text', 'name', 'Author', false, $comment['name']);
$form->addInput('email', 'email', 'E-mail', true, $comment['email']);
$form->addTextArea('comment', 'Comment', true, $comment['comment'], 2);
$form->addSubmit('save', 'Save');
if ($form->isValid()) {
$auth = new Auth($this->db);
$saveData = $form->values();
$saveData['updated'] = new NotORM_Literal("NOW()");
$commentSave = $comment->update($saveData);
if ($commentSave) {
$this->addMessage('success', 'Comment saved');
$this->redirect('admin/comments');
} else {
$form->error();
}
}
$data['editForm'] = $form->formHtml();
$data['isAdmin'] = true;
$this->renderTemplate('comment/edit', $data);
}
示例2: actionEdit
/**
* Admin - edit post
*
* @param integer $id ID of post
* @return void
*/
public function actionEdit($id = null)
{
// authorization
$this->checkAuth();
$data = array();
$data['page_title'] = 'New post';
$post = array('title' => '', 'uri' => '', 'annotation' => '', 'content' => '', 'category_id' => '');
if (!is_null($id)) {
$post = $this->db->post[$id];
if ($post) {
$data['page_title'] = 'Edit post';
} else {
$this->notFound();
}
}
// Form
$form = new Forms('postEdit');
$form->successMessage = 'Your post was saved.';
$form->errorMessage = 'Error while saving post. Try it later.';
$form->addInput('text', 'title', 'Title', true, $post['title']);
$form->addInput('text', 'uri', 'URI', false, $post['uri']);
// categories
$categories = array('' => '= Choose category =');
foreach ($this->db->category() as $category) {
$categories[$category['id']] = $category['title'];
}
$form->addSelect('category_id', 'Category', $categories, true, $post['category_id']);
$form->addTextArea('annotation', 'Annotation', true, $post['annotation']);
$form->addTextArea('content', 'Content', true, $post['content']);
$form->addSubmit('save', 'Save');
if ($form->isValid()) {
$auth = new Auth($this->db);
$saveData = $form->values();
$saveData['uri'] = trim($saveData['uri']);
if ($saveData['uri'] == "") {
$saveData['uri'] = $saveData['title'];
}
$saveData['uri'] = $this->text2url($saveData['uri']);
$saveData['user_id'] = $auth->userInfo()->id;
$saveData['updated'] = new NotORM_Literal("NOW()");
if (is_null($id)) {
$saveData['created'] = new NotORM_Literal("NOW()");
$postSave = $this->db->post()->insert($saveData);
} else {
$postSave = $this->db->post[$id]->update($saveData);
}
if ($postSave) {
$this->addMessage('success', 'Post saved');
$this->redirect('admin');
// $form->success();
} else {
$form->error();
}
}
$data['editForm'] = $form->formHtml();
$data['isAdmin'] = true;
$this->renderTemplate('post/edit', $data);
}
示例3: actionEdit
/**
* Edit category
* @return void
*/
public function actionEdit($id = null)
{
// authorization
$this->checkAuth();
$data = array();
$data['page_title'] = 'New category';
$category = array('title' => '', 'uri' => '');
if (!is_null($id)) {
$category = $this->db->category[$id];
if ($category) {
$data['page_title'] = 'Edit category';
} else {
$this->notFound();
}
}
// Form
$form = new Forms('categoryEdit');
$form->successMessage = 'Your category was saved.';
$form->errorMessage = 'Error while saving category. Try it later.';
$form->addInput('text', 'title', 'Title', true, $category['title']);
$form->addInput('text', 'uri', 'URI', false, $category['uri']);
$form->addSubmit('save', 'Save');
if ($form->isValid()) {
$auth = new Auth($this->db);
$saveData = $form->values();
$saveData['uri'] = trim($saveData['uri']);
if ($saveData['uri'] == "") {
$saveData['uri'] = $saveData['title'];
}
$saveData['uri'] = $this->text2url($saveData['uri']);
$saveData['updated'] = new NotORM_Literal("NOW()");
if (is_null($id)) {
$categorySave = $this->db->category()->insert($saveData);
} else {
$categorySave = $this->db->category[$id]->update($saveData);
}
if ($categorySave) {
$this->addMessage('success', 'Category saved');
$this->redirect('admin/categories');
// $form->success();
} else {
$form->error();
}
}
$data['editForm'] = $form->formHtml();
$data['isAdmin'] = true;
$this->renderTemplate('category/edit', $data);
}
示例4: actionRegister
/**
* Create user
* @return void
*/
public function actionRegister()
{
// if user is logged in, redirect to main page
if ($this->checkLogin()) {
$this->redirect('admin');
}
$form = new Forms('create');
$form->successMessage = 'Account succesfully created.';
$form->errorMessage = 'Error while creating account. Try it later.';
$form->addInput('text', 'name', 'Full name', true);
$form->addInput('email', 'email', 'E-mail', true);
$form->addInput('password', 'password', 'Password', true);
$form->addSubmit('create', 'Create account');
if ($form->isValid()) {
$formValues = $form->values();
$userCheck = $this->db->user()->where('email', $formValues['email'])->count('id');
if ($userCheck > 0) {
$form->addMessage('warning', 'User with e-mail ' . $formValues['email'] . ' exists. LogIn or type other e-mail.');
} else {
$auth = new Auth($this->db);
if ($auth->addUser($formValues['email'], $formValues['password'], $formValues['name'])) {
$auth->checkUser($formValues['email'], $formValues['password']);
$this->redirect('admin');
} else {
$form->error();
}
}
}
$data['registerForm'] = $form->formHtml();
$this->renderTemplate('admin/register', $data);
}