Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to return the form validation back in cakePHP
    text
    copied!<p>i need to return the form validation because i lost it after submitting </p> <p>i'm on News/view/30 ---view a report details---- in that page we have add comment Form :</p> <pre><code> &lt;h2&gt;Add comment&lt;/h2&gt; &lt;?php echo $this-&gt;Form-&gt;create("Comment", array( 'url' =&gt; array('controller' =&gt; 'Comments', 'action' =&gt; 'add') )); echo $this-&gt;Form-&gt;label("name"); echo $this-&gt;Form-&gt;input("name", array("label" =&gt; false, "class" =&gt; "textfield")); echo $this-&gt;Form-&gt;label("email"); echo $this-&gt;Form-&gt;input("email", array("label" =&gt; false, "class" =&gt; "textfield")); echo $this-&gt;Form-&gt;label("text"); echo $this-&gt;Form-&gt;textarea("text", array("label" =&gt; false)); echo $this-&gt;Form-&gt;input("object_id", array("type" =&gt; "hidden", "value" =&gt; $data['News']['id'])); echo $this-&gt;Form-&gt;input("type", array("type" =&gt; "hidden", "value" =&gt; "news")); echo $this-&gt;Html-&gt;Link("Add Comment", "#", array("class" =&gt; "add_button", "onclick" =&gt; "$('#CommentViewForm').submit()")); echo $this-&gt;Form-&gt;end(); ?&gt; </code></pre> <p>the form is submiting on Comment controller :</p> <p>in comment/add :</p> <pre><code> $isSuccess = $this-&gt;Comment-&gt;save($this-&gt;request-&gt;data); if ($isSuccess) { $this-&gt;Session-&gt;setFlash('your Comments has been added successfully and pending admin aproval.thanks ', 'default', array(), 'good'); } else { $this-&gt;Session-&gt;setFlash('Failed to add your comment: &lt;br/&gt;Fill all the required fileds &lt;br/&gt;type correct Email', 'default', array(), 'bad'); } $this-&gt;redirect(array("controller" =&gt; "News", "action" =&gt; "view", $id)); </code></pre> <p>i did some validation rules on name,email and the comment itself when there are errors in user inputs return to add Comment Form but didnt show the errors as usual </p> <p>i hope you understand me very well, and i wait your help thank alot</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload