Welcome Guest, Not a member yet? Register   Sign In
Populate input field with controller
#1

[eluser]freshface[/eluser]
Hey

I have a form witch validation from this example: http://ellislab.com/codeigniter/user-gui...ation.html
But the value field is allready taken. Can i populate the input field with my controller and how?

Thx in advance
#2

[eluser]xadio[/eluser]
Are you meaning like a search box which contains the work "Search..." and upon clicking it clears, or are you referring to actual data in the field, like "Zip Code: 000000" which would be generated by an geoip lookup?

The first should be handled by Javascript, but the second could possibly* be set through
Code:
if(!isset($_POST['zipcode'])) {
  $_POST['zipcode'] = 00000;
}
in the controller.

*I don't have a test environment set up to test it, but that is how I would assume the Validation library works because $this->load->library('validation'); is loaded in the controller's method not constructor.
#3

[eluser]freshface[/eluser]
Solved it like this:

Code:
if (count($_POST) == 0)
                {
                  $data['selected_country'] =  $data['row']->country_iso;
                    $data['selected_vat_percentage'] = $data['row']->vat_percentage_id;
                    $data['selected_taxable'] =  $data['row']->taxable;
                }




Theme © iAndrew 2016 - Forum software by © MyBB