Shathee Ruhunnabi
Shathee Ruhunnabi

Reputation: 103

Form Validation - Modify Second Parameter in codeigniter

Is it possible to modify the second parameter for a custom callback?

<pre>
<code>

$something = 14 
$this->form_validation->set_rules('name', 'Name', 'callback_valid_name['.$something.']'); 
public function valid_name($value, $something) {
$something = 20

 } 
 </code>
</pre>

Say I want to pass something to a custom callback. For example, I pass $something and it is equal to 14. After it gets passed and the callback function returns, $something is no equal to 20. Does that make sense?

I am not having any luck with this so far.

Upvotes: 2

Views: 358

Answers (1)

Andrew
Andrew

Reputation: 6394

set_rules passes the name value to the callback function. You could define the something variable as a class variable and have access to it from all the methods in the class.

Upvotes: 3

Related Questions