[eluser]valarkin[/eluser]
[quote author="Yash" date="1217722241"]Load validation library ?[/quote]
Code:
function Parties()
{
parent::Controller();
$this->load->helper(array('form', 'url'));
$this->load->library('validation');
$this->output->enable_profiler(TRUE);
}
[quote author="Yash" date="1217722241"]There will be not data untill you submit the form.[/quote]
The form has been submitted. Profiler shows me all the posted data, and the data IS being validated. However, when I call:
Code:
$this->load->view('parties_birthday_reservation');
The variables: $this->validate->conFirstName contains nothing.
[quote author="Yash" date="1217722241"]In your view file I can't any Form?Please show full view and controller.[/quote]
Here is the Controller:
Code:
<?php
class Parties extends Controller {
function Parties()
{
parent::Controller();
$this->load->helper(array('form', 'url'));
$this->load->library('validation');
$this->output->enable_profiler(TRUE);
}
function index()
{
$this->load->view('parties');
}
function birthday_reservation() {
$action = $this->uri->segment(3);
switch ($action) {
case "submit":
$this->_validateBirthdayReservation();
break;
case "form":
$this->load->view('parties_birthday_reservation');
break;
}
}
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;
echo $this->validation->conFirstName;
$this->load->view('parties_birthday_reservation');
} else {
//$this->load->view('formsuccess');
echo "The form passed all test!";
}
}
}
?>
There isn't enough space for the view. But everything is done the same way as the section that was in my first post.