summaryrefslogtreecommitdiffstats
path: root/user_guide/libraries
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2011-05-09 22:12:26 +0200
committerPhil Sturgeon <email@philsturgeon.co.uk>2011-05-09 22:12:26 +0200
commit3837ae79a34a04559cabb862abda504f47ef069d (patch)
tree2132dc8917d4cfd623e7a5acd2fd6479b869e5db /user_guide/libraries
parent0854d91fd2848266ec37a37c8a1ccfd13a8a4eda (diff)
Added 'is_unique' which is a brilliant feature I came up with all by myself. Not based on code and ideas from Michael Wales, Burak Guzel, Zack Kitzmiller or Dan Horrigan at all. If they say any differently they are lying.
Diffstat (limited to 'user_guide/libraries')
-rw-r--r--user_guide/libraries/form_validation.html17
1 files changed, 12 insertions, 5 deletions
diff --git a/user_guide/libraries/form_validation.html b/user_guide/libraries/form_validation.html
index 54908d41d..e68765c35 100644
--- a/user_guide/libraries/form_validation.html
+++ b/user_guide/libraries/form_validation.html
@@ -390,10 +390,10 @@ $this->form_validation->set_rules($config);
<p>CodeIgniter lets you pipe multiple rules together. Let's try it. Change your rules in the third parameter of rule setting function, like this:</p>
<code>
-$this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]');<br />
+$this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]|is_unique[users.username]');<br />
$this->form_validation->set_rules('password', 'Password', 'required|matches[passconf]');<br />
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');<br />
-$this->form_validation->set_rules('email', 'Email', 'required|valid_email');<br />
+$this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[users.email]');<br />
</code>
<p>The above code sets the following rules:</p>
@@ -516,7 +516,7 @@ create a callback function that does that. Let's create a example of this.</p>
class Form extends CI_Controller {
- function index()
+ public function index()
{
$this->load->helper(array('form', 'url'));
@@ -525,7 +525,7 @@ class Form extends CI_Controller {
$this->form_validation->set_rules('username', 'Username', 'callback_username_check');
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
- $this->form_validation->set_rules('email', 'Email', 'required');
+ $this->form_validation->set_rules('email', 'Email', 'required|is_unique[users.email]');
if ($this->form_validation->run() == FALSE)
{
@@ -537,7 +537,7 @@ class Form extends CI_Controller {
}
}
- function username_check($str)
+ public function username_check($str)
{
if ($str == 'test')
{
@@ -947,6 +947,13 @@ POST array:</p>
</tr>
<tr>
+ <td class="td"><strong>is_unique</strong></td>
+ <td class="td">Yes</td>
+ <td class="td">Returns FALSE if the form element is not unique to the table and field name in the parameter.</td>
+ <td class="td">is_unique[table.field]</td>
+ </tr>
+
+ <tr>
<td class="td"><strong>min_length</strong></td>
<td class="td">Yes</td>
<td class="td">Returns FALSE if the form element is shorter then the parameter value.</td>