public function handleComment($data, $form) { $comment = ArticleComment::create(); $comment->Name = $data['Name']; $comment->Email = $data['Email']; $comment->Comment = $data['Comment']; $comment->ArticleID = $this->ID; $comment->write(); $form->sessionMessage('Thanks for your comment!', 'good'); return $this->redirectBack(); }
public function handleComment($data, $form) { Session::set("FormData.{$form->getName()}.data", $data); $existing = $this->Comments()->filter(array('Comment' => $data['Comment'])); if ($existing->exists() && strlen($data['Comment']) > 20) { $form->sessionMessage('That comment already exists! Spammer!', 'bad'); return $this->redirectBack(); } $comment = ArticleComment::create(); $comment->ArticlePageID = $this->ID; $form->saveInto($comment); $comment->write(); Session::clear("FormData.{$form->getName()}.data"); $form->sessionMessage('Thanks for your comment', 'good'); return $this->redirectBack(); }
public function handleComment($data, $form) { //store the info in the session so that the user field will not empty after the validation Session::set("FormData.{$form->getName()}.data", $data); //this->Commets = the $has_many value is Comments $existing = $this->Comments()->filter(array('Comment' => $data['Comment'])); if ($existing->exists() && strlen($data['Comment']) > 0) { $form->sessionMessage('That comment already exists!', 'bad'); //if everything checkout we cleare it. Session::clear('$FormData.{$form->getName()}.data'); return $this->redirectBack(); } $comment = ArticleComment::create(); $comment->Name = $data['Name']; $comment->Email = $data['Email']; $comment->Comment = $data['Comment']; $comment->ArticlePageID = $this->ID; $comment->write(); $form->sessionMessage('Thanks for your comment', 'good'); return $this->redirectBack(); }