All pastes #510037 Raw Edit

Someone

public text v1 · immutable
·published 2007-05-25 18:55 UTC
rendered paste body
function create()
	{
		$this->load->library("forge");
		$conf["action"] = "client/create";
		$conf["form_name"] = "Create New Client";
		
		$this->forge->initialize($conf);
				
		$default = array("rules" => "required");
		$default_input = array('style' => 'width: 250px;', 'rules' => 'required');
		
		$this->forge->add("company_name", 				"text",		$default_input);
		$this->forge->add("billing_name", 				"text",		$default_input);
		$this->forge->add("billing_address", 			"textarea",	array('style' => 'height: 50px; width: 250px;', 'rules' => 'required'));
		$this->forge->add("billing_city",				"text",		$default_input);
		$this->forge->add("billing_state", 				"dropdown",	array('options' => $this->customfunctions->states(), 'selected' => "WI"));
		$this->forge->add("billing_zip", 				"text",		array('rules' => 'required[5,5]', 'style' => 'width: 250px;'));
		$this->forge->add("copy_to_contact", 			"checkbox",	array('value' => true));
		$this->forge->add("contact_name",				"text",		$default_input);
		$this->forge->add("contact_address", 			"textarea",	array('style' => 'height: 50px; width: 250px;', 'rules' => 'required'));
		$this->forge->add("contact_city", 				"text",		$default_input);
		$this->forge->add("contact_state", 				"dropdown",	array('options' => $this->customfunctions->states(), 'selected' => "WI"));
		$this->forge->add("contact_zip", 				"text",		array('rules' => 'required[5,5]', 'style' => 'width: 250px;'));
		$this->forge->add("phone_number", 				"telephone",$default);
		$this->forge->add("fax_number", 				"telephone", array('rules' => ''));
		$this->forge->add("bookkeeper_name", 			"text",		array('style' => 'width: 250px;'));
		$this->forge->add("tax_exempt", 				"checkbox",	array('value' => true));
		$this->forge->add("create",						"submit",	array('value' => 'Create Client'));
		
		if ($post = $this->forge->post_data()) 
		{
			if ($id = $this->clientmodel->create_client($post))
				redirect('client/view/' . $id);
			else
				die('an error occured');
		}
		else
		{
			$data = array(	"view" => "client/create",
							"render_header" => true,
							"render_footer" => true,
							"header" => "header",
							"left_menu" => $this->left_menu,
							"top_menu" => $this->top_menu,
							"title" => "IM Project Management :: Create New Client"
							);
			$this->load->view('layout', $data);
		}
	}