Welcome Guest, Not a member yet? Register   Sign In
Validation fails to fill form elements or error message.
#1

[eluser]valarkin[/eluser]
I am working on a reservation tool and am having problems with the validation. When I validate the information it fails and calls the load view method. However, none of the fields populate, nor does the error message populate.If I echo the error field before loading the view I can see all the errors.

Any ideas what might be causing this?

Here is some code of the code:

(Controller Function that handles Validation)
Code:
function _validateBirthdayReservation() {    
        
        $rules['conFirstName']        = "trim|required";
        $rules['conLastName']        = "required";
        $rules['conAddress']        = "required";
        $rules['conCity']            = "required";
        $rules['conState']            = "required";
        $rules['conZip']            = "required";        
        $rules['conEMail']            = "required";
        $rules['conPhone']            = "required";
        $rules['childFirstName']    = "required";
        $rules['childLastName']        = "required";
        $rules['childDOBDay']        = "required";
        $rules['childDOBMonth']        = "required";
        $rules['childDOBYear']        = "required";
        $rules['childFavColor']        = "required";
        $rules['partyDateDay']        = "required";
        $rules['partyDateMonth']    = "required";
        $rules['partyDateYear']        = "required";
        $rules['partyTime']            = "required";
        $rules['partySodaType']        = "required";
        $rules['partyPizzaType']    = "required";
        $rules['partyNbrKids']        = "required";
        $rules['ccHolderName']        = "required";
        $rules['ccType']            = "required";
        $rules['ccNumber']            = "required";
        $rules['ccExpDateMonth']    = "required";
        $rules['ccExpDateYear']        = "required";

        $this->validation->set_rules($rules);
        
        $fields['conFirstName']        = "Contact First Name";
        $fields['conLastName']        = "Contact Last Name";
        $fields['conAddress']        = "Contact Address";
        $fields['conCity']            = "Contact City";
        $fields['conState']            = "Contact State";
        $fields['conZip']            = "Contact Zip";    
        $fields['conEMail']            = "Contact E-Mail";
        $fields['conPhone']            = "Contact Phone";
        $fields['childFirstName']    = "Child's First Name";
        $fields['childLastName']    = "Child's Last Name";
        $fields['childDOBDay']        = "Child's Date of Birth: Day";
        $fields['childDOBMonth']    = "Child's Date of Birth: Month";
        $fields['childDOBYear']        = "Child's Date of Birth: Year";
        $fields['childFavColor']    = "Child's Favorit Color";
        $fields['partyDateDay']        = "Party Date: Day";
        $fields['partyDateMonth']    = "Party Date: Month";
        $fields['partyDateYear']    = "Party Date: Year";
        $fields['partyTime']        = "Party Time";
        $fields['partySodaType']    = "Party Soda Type";
        $fields['partyPizzaType']    = "Party Pizza Type";
        $fields['partyNbrKids']        = "Number of Kids";
        $fields['ccHolderName']        = "Credit Card Holder Name";
        $fields['ccType']        = "Credit Card Type";
        $fields['ccNumber']            = "Credit Card Number";
        $fields['ccExpDateMonth']    = "Credit Card Expiration: Month";
        $fields['ccExpDateYear']    = "Credit Card Expiration: Year";
        
        $this->validation->set_fields($fields);
        
        if (!$this->validation->run()) {
            //echo $this->validation->error_string;
            $this->load->view('parties_birthday_reservation');
        } else {
            //$this->load->view('formsuccess');
            echo "The form passed all test!";
        }
    }

(A part of the View 'parties_birthday_reservation')

Code:
<label id="conZip-label">Zip:
        &lt;input id="conZip-input" name="conZip" type="text" value="&lt;?=$this-&gt;validation->conZip;?&gt;">
        </label>
        <label id="conEMail-label">E-Mail Address:
        &lt;input id="conEMail-input" name="conEMail" type="text" value="&lt;?=$this-&gt;validation->conEMail;?&gt;">
        </label>
        <label id="conPhone-label">Phone Number:
        &lt;input id="conPhone-input" name="conPhone" type="text" value="&lt;?=$this-&gt;validation->conPhone;?&gt;">
        </label>

(Another part of the View 'parties_birthday_reservation' that handles the error information)
Code:
&lt;?php if ($this->validation->error_string <> ''): ?&gt;
      <div style="float:left; margin-left:10px; width: 310px; padding:10px; border: solid 1px #FF0000; margin-top:10px; color:#FF0000;">
      Error(s): <br />
      &lt;?=$this->validation->error_string;?&gt;
      </div>
      &lt;?php endif; ?&gt;

Any thoughts?


Messages In This Thread
Validation fails to fill form elements or error message. - by El Forum - 08-02-2008, 12:35 PM



Theme © iAndrew 2016 - Forum software by © MyBB