codeignitercodeigniter-form-helper

how to pass parameters to controller from view


I need to pass parameters from a view to control in a form. These parameters are for example a string that is not in a textField. The string is "FATHER" and I send this string from the view to the controller when I click on the submit button in the form. Anyone can suggest how I can do it?


Solution

  • add a hidden input field to your form with a value of "FATHER":

    <?= form_hidden('name_of_field', 'FATHER') ?>
    

    and in your controller, get the value when the form is submitted:

    $value = $this->input->post('name_of_field');