CodeIgniter Forums
something small, but i don't understand - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: something small, but i don't understand (/thread-53513.html)



something small, but i don't understand - El Forum - 07-27-2012

[eluser]Unknown[/eluser]
I have trouble when i want to validate my form,
this is my view:

<table width=70%>
<tr >
<td colspan="3" height="50"> <h3>Tambah User</h3></td>
</tr>
<tr >
<td> Username </td>
<td> : </td>
<td> &lt;?php echo form_input('username',set_value('username'),'id="search-text"'); ?&gt;
<font color="#FF0000">&lt;?php echo form_error('username','<div class="warning">','</div>'); ?&gt; </font></td>
</tr>
<tr>
<td> Password</td>
<td> : </td>
<td> &lt;?php echo form_input('password',set_value('password'),'id="search-text"'); ?&gt;
<font color="#FF0000">&lt;?php echo form_error('password','<div class="warning">','</div>'); ?&gt;</font></td>
</tr>
<tr>
<td> Jenis user</td>
<td> : </td>
<td> <select name="jenis_user">
<option value="admin">Admin</option>
<option value="pengelola_barang">Pengelola barang</option>
<option value="kepala_skpd">Kepala SKPD</option>
</select>
</td>
</tr>
<tr>


and this is the controller function when i submit:

function add_proses() {

$this->load->library('form_validation');
$this->form_validation->set_value('username','username'.'required | min_length=[3]');
$this->form_validation->set_value('password','password'.'required | min_length=[3]');
$this->form__validation->set_message('required','data masukan tidak sesuai');
if($this->form_validation->run() == FALSE){
$this->load->view('admin/tambah_user');

}
else{
$this->load->model('m_user');
$this->m_user->setUser();
redirect('data_user/tampil');

}

}

but the output is
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Data_user::$form__validation

Filename: controllers/data_user.php

Line Number: 52


i use ci 1.7.2.. please help me..


something small, but i don't understand - El Forum - 07-27-2012

[eluser]Felipe Deitos[/eluser]
I am from Brazil so sorry for any english problem... i am new to CI..
Here we go... its hard to read you code, next time you should put the code inside a [ code ] tag

Can u tell us what is the line 52?

In this line:
Code:
$this->form__validation->set_message(‘required’,‘data masukan tidak sesuai’);
You have a double underscore...

In this lines:
Code:
$this->form_validation->set_value(‘username’,‘username’.‘required | min_length=[3]’);
$this->form_validation->set_value(‘password’,‘password’.‘required | min_length=[3]’);
You have a "." instead a ","

If those 2 things dont solve you problem, try to post your entire code, inside de code tags, and show us the line 52.




something small, but i don't understand - El Forum - 07-27-2012

[eluser]PhilTem[/eluser]
The problem is, as your PHP interpreter tells you, in

Code:
Message: Undefined property: Data_user::$form__validation

Now have a close look at the line that causes the problem
Code:
$this->form__validation->set_message(‘required’,‘data masukan tidak sesuai’);

and tell me what the main difference between this line and the latter is

Code:
$this->form_validation->set_message(‘required’,‘data masukan tidak sesuai’);