Welcome Guest, Not a member yet? Register   Sign In
Noob question about passing multiple form fields to a model. Be gentle
#1

[eluser]ThanksBrah[/eluser]
Hello,
new to code igniter and I have a question about passing form data.

I'm building a search form that allows the user to select multiple dropdown boxes to refine their search.

my question is what is the best practice for multiple fields to a model. I can do it with one input of course,

but this has me stumped.


here's my view

Code:
<?=form_open('advanced/search');?>
   <section class="row-fluid">
    <section class="span3">

      <fieldset>
       <legend>
        Search Option
       </legend>
       <label class="checkbox inline">
         &lt;input type="checkbox" id="inlineCheckbox1" value="option1"&gt; and
       </label>
       <label class="checkbox inline">
         &lt;input type="checkbox" id="inlineCheckbox2" value="option2"&gt; or
       </label>
      </fieldset>

    </section>
    
    <section class="span9">
    
     &lt;?php
         echo form_fieldset('Basic Search');
               echo form_label('Find an Intervention');  
         $data = array(
                      'name'        => 'name',
                      'class'          => 'input-block-level',
                      'value'       => ''
                        );

            echo form_input($data);
                        echo form_fieldset_close();
                       ?&gt;
  
    </section>
    
   </section>
  
   <section class="row-fluid">
    <section class="span6">
    
        &lt;?php
         echo form_fieldset('Overall Designation');
               echo form_label('Intervention Effectiveness');  
           $options = array(
                        'selected'  => 'Select one...',
                        'Effective'    => 'Effective',
                        'Unproven'   => 'Unproven',
                        'Iatrogenic' => 'Iatrogenic');
      
                        echo form_dropdown('effective', $options, 'selected');
                        echo form_fieldset_close();
                       ?&gt;
    
    </section>

    <section class="span6">

       &lt;?php
       echo form_fieldset('Target Population');
       echo form_label('Grade Level Intervention');
                             $options = array(
                        'selected'  => 'Select one...',
                        'Elementary'    => 'Elementary',
                        'Middle School'   => 'Middle School',
                        'High School' => 'High School');
        
             echo form_dropdown('target', $options, 'selected');
                            echo form_fieldset_close();
                            ?&gt;    
        
        
    
    
    </section>
    
   </section>
  
   <section class="row-fluid">

    <section class="span6">
  
      &lt;?php
       echo form_fieldset('Outcome Category');
       echo form_label('Outcome of Intervention');
                             $options = array(
                        'selected'  => 'Select one...',
                        'Risk Behavior'    => 'Risk Behavior',
                        'Competencies'   => 'Pro-Social Competencies',
                        'School Based outcome' => 'School-Based outcome',
                        'Emotional' => 'General Social-Emotional');
        
             echo form_dropdown('outcomes', $options, 'selected');
                            echo form_fieldset_close();
                            ?&gt;    
          </section>
    
    <section class="span6">
    
      &lt;?php
       echo form_fieldset('Implementation Strategy');
       echo form_label('Content and Pedagogical Elements');
                             $options = array(
                        'selected'  => 'Select one...',
                        'Explicit Chatacter Education Program'    => 'Explicit Chatacter Education Program',
                        'Social and Emotional Curriculum'   => 'Social and Emotional Curriculum',
                        'Academic Curriculum Integration' => 'Academic Curriculum Integration',
                        'Direct Teaching Strategies' => 'Direct Teaching Strategies',
                        'Interactive Teaching Learning Strategies' => 'Interactive Teaching/Learning Strategies',
                        'Classroom Behavior Management Strategies'   => 'Classroom/Behavior Management Strategies',
                        'Modeling Mentoring' => 'Modeling/Mentoring',
                        'Family Community Participation<s' => 'Family Community Participation',
                        'Community Service Service Learning' => 'Community Service/Service Learning',
                        'Profesional Development' => 'Profesional Development');
        
             echo form_dropdown('strategy', $options, 'selected');
                            echo form_fieldset_close();
                            ?&gt;
                            
                           &lt;?php
                            $search = array(

            array(
                 'field'   => 'name'
              
            ),
            array(
                 'field'   => 'effective',
                
            ),
            array(
                 'field'   => 'target',
            
            ),
            array(
                 'field'   => 'outcomes',
                
            ),
            array(
                 'field'   => 'stratergy',
                
            )
            
        
        );
                                    
      ?&gt;                          
                                    
                                

      &lt;?=form_input($search);?&gt;&lt;input type=submit value='Search' class='btn'/&gt;
      
    
    </section>
  &lt;?=form_close();?&gt;
   </section>

I've tried passing the data in array,

Your help is greatly appreciated.

thanks in advance.
#2

[eluser]boltsabre[/eluser]
You can access the entire $_POST array in the model (without needing to manually pass it from your controller) with:
Code:
$this->input->post();
And individual $_POST items like this:
Code:
$this->input->post("some_form_input_name");
#3

[eluser]ThanksBrah[/eluser]
thanks for the response.

I figured most of it out last night.




Theme © iAndrew 2016 - Forum software by © MyBB