本文整理汇总了PHP中Forms::success方法的典型用法代码示例。如果您正苦于以下问题:PHP Forms::success方法的具体用法?PHP Forms::success怎么用?PHP Forms::success使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Forms
的用法示例。
在下文中一共展示了Forms::success方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionView
/**
* Post detail
* @param string $uri URI of post
*/
public function actionView($uri)
{
/**
* Post data
*/
$post = $this->db->post()->where('uri', $uri)->fetch();
if ($post) {
$data['page_title'] = $post['title'];
} else {
$this->notFound();
}
$data['post'] = $post;
$data['postComments'] = $this->db->comment()->where('post_id', $post['id'])->order('created DESC');
/**
* Comments
*/
$form = new Forms('newComment');
$form->successMessage = 'Your comment was saved.';
$form->errorMessage = 'Error while saving comment. Try it later.';
$form->addInput('text', 'name', 'Name');
$form->addInput('email', 'email', 'E-mail', true);
$form->addTextArea('comment', 'Your comment', true, '', 2);
$form->addSubmit('send', 'Send commment');
if ($form->isValid()) {
$formValues = $form->values();
$saveComment = $this->db->comment()->insert(array('post_id' => $post['id'], 'name' => $formValues['name'] ? $formValues['name'] : null, 'email' => $formValues['email'] ? $formValues['email'] : null, 'comment' => $formValues['comment'] ? $formValues['comment'] : null, 'created' => new NotORM_Literal("NOW()"), 'ip' => $this->realClientIp()));
if ($saveComment) {
$form->success();
} else {
$form->error();
}
}
$data['comment_form'] = $form->formHtml();
$this->renderTemplate('post/view', $data);
}