Welcome Guest, Not a member yet? Register   Sign In
Set value doesn,t return the value CI 2.0
#1

[eluser]JuanitoDelCielo[/eluser]
I have one form to search

Code:
<?php echo form_open($search); ?>
<fieldset>
&lt;?php echo form_label('q', 'Buscar', array('class' => 'a-hidden')); ?&gt;
&lt;?php
$input = array(
'class' => 'text fl',
'name'  => 'q',
'value' => set_value('q', 'Search')
);
echo form_input($input);
?&gt;
</fieldset>

And it works, and using the profiler I know the value

POST DATA
$_POST['q'] Search String

So the input field should have the search String but it always show Search

Any ideas?
#2

[eluser]InsiteFX[/eluser]
Thats because you have to post to controller/method!
Code:
echo form_open('email/send');

InsiteFX
#3

[eluser]JuanitoDelCielo[/eluser]
This is the value of $search

Code:
$data->search = 'classified/index';
#4

[eluser]bEz[/eluser]
Are you sending $data as an object instead of as an array?

Code:
$data['search'] = 'classified/index';
#5

[eluser]JuanitoDelCielo[/eluser]
Yes but its the same. If you read the Loader.php code you will find this:

Code:
function view($view, $vars = array(), $return = FALSE)
{
    return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
}

...

function _ci_object_to_array($object)
{
    return (is_object($object)) ? get_object_vars($object) : $object;
}

get_object_vars
#6

[eluser]JuanitoDelCielo[/eluser]
It was really easy. Just add a simple rule to via the form validataion class.




Theme © iAndrew 2016 - Forum software by © MyBB