Note that there are some explanatory texts on larger screens.

plurals
  1. POEmail validation error message - CakePHP
    primarykey
    data
    text
    <p>My User model:</p> <pre><code>class User extends AppModel { public $validate = array( 'username' =&gt; 'alphaNumeric', 'password' =&gt; 'notempty', 'confirmpassword' =&gt; 'notempty', 'group_id' =&gt; 'notempty', 'email' =&gt; array( 'rule' =&gt; 'email', 'message' =&gt; 'Please provide a valid email address.' ), ); } </code></pre> <p>My User Registration view:</p> <pre><code>&lt;div class="users form"&gt; &lt;?php echo $this-&gt;Form-&gt;create('User'); ?&gt; &lt;fieldset&gt; &lt;legend&gt;&lt;?php echo __('Register User'); ?&gt;&lt;/legend&gt; &lt;?php echo $this-&gt;Form-&gt;input('User.username'); echo $this-&gt;Form-&gt;input('User.password'); echo $this-&gt;Form-&gt;input('User.confirmpassword', array('type'=&gt;'password', 'label'=&gt;'Confirm password')); echo $this-&gt;Form-&gt;input('User.group_id'); echo $this-&gt;Form-&gt;input('User.email'); ?&gt; &lt;/fieldset&gt; &lt;?php echo $this-&gt;Form-&gt;end(__('Submit')); ?&gt; &lt;/div&gt; </code></pre> <p>My User Registration action in the Controller:</p> <pre><code>public function register() { if ($this-&gt;request-&gt;is('post')) { ... //create mail for verification $email = new CakeEmail(); ... $email-&gt;to($this-&gt;data['User']['email']); $email-&gt;send($ms); } } </code></pre> <p>Accessing /users/register, When I enter something like 'asdfgh' in the e-mail field, I get the default CakePHP error message:</p> <pre><code>Invalid email: asdfgh Error: An Internal Error Has Occurred. </code></pre> <p>Instead of an error message above the e-mail field, telling me:</p> <pre><code>Please provide a valid email address. </code></pre> <p>My question: Should it really call the action in the controller when the user's input data is invalid? Is there a way to call the action in the controller only if the user's input data is valid?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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