codeigniter-form-helper

How to avoid “The action you have requested is not allowed” error with Knockout postJson function call

核能气质少年 提交于 2020-01-05 04:31:08
问题 CodeIgniter gives an error "The action you have requested is not allowed." when it fails the check for CSRF. As I understand it, this means the POST is missing the hidden token from the form that proves that an attack is not being done. The token is generated automatically with a call to the CI form_open function. In my case, I'm using Knockout to post the contents of a ViewModel for saving, like this: ko.utils.postJson($("form")[0], self.pages); I've found solutions elsewhere that simply

Codeigniter doesn't let me update entry, because some fields must be unique

跟風遠走 提交于 2019-12-24 04:03:12
问题 So what I'm trying to do: Pull User data from database, including email address, username etc. Edit it Save it But I want to keep username and email unique. And for this I'm setting validation rules like this: $this->form_validation->set_rules('firstname', 'First Name', 'required|min_length[2]|max_length[15]'); $this->form_validation->set_rules('lastname', 'Last Name', 'required|min_length[2]|max_length[15]'); $this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique

select box validation in Codeigniter

孤街醉人 提交于 2019-12-21 05:18:13
问题 i am new to Codeigniter and I have some trouble in select box validation. I want default select value at beginning. <select name="schooGroups[]"> <option value="0">Select User Group</option> <option value="1">Admin</option> </select> how can i make it required field in form and display error message on select of zero "0" value. 回答1: This will have the entry marked as "selected" as...selected by default. You want a multi-select dropdown, right? <select name="schoolGroups[]" multiple="multiple"

Trying to populate a dropdown menu in codeigniter with mysql data

血红的双手。 提交于 2019-12-20 07:18:56
问题 Im trying to populate a dropdown box on a registraton form in code igniter but i have had not luck below are snippets from my contorller, model, and view. Base is the drop down field. Model function get_airports() { $this->db->select('airport_code, airport_name'); $this->db->order_by('airport_code', "asc"); $query = $this->db->get('airports'); if($query){ $query = $query->result_array(); return $query; } } }return $data } function create_member() { $new_member_insert_data = array('first_name'

error: Undefined property: News::$form_validation in codeigniter

老子叫甜甜 提交于 2019-12-11 13:46:12
问题 I am new to the codeigniter and trying the tutorials in the user guide. But i stuck i the third tutorial which is for the create news items. Here in my controller section it is giving the following error: Severity: Notice Message: Undefined property: News::$form_validation Filename: controllers/news.php Line Number: 44 and the code that i used in the controller section is public function create() { $this->load->helper('form'); $this->load->library('form_validation'); $data['title'] = 'Create

How to create forms with conditional options

China☆狼群 提交于 2019-12-11 10:50:24
问题 I want to create a form with two dropdown boxes so that the options in the second dropdown depend on the choices in the first dropdown. So Dropdown1 might ask the user to opt for CourseA or CourseB and Dropdown2 might present sets of dates - but the dates would differ depending on what the choice in Dropdown1 had been. I have tried using the post array to set the Dropdown2 choices but then realized that it is not set until the form is submitted. My problem happens before the form is submitted

Codeigniter - Form helper set_select()

寵の児 提交于 2019-12-10 16:45:10
问题 How can I use set_select() (part of the form helper) on my dropdown array in codeigniter: It is used to remember which option the user has selected. $guide_options = array('investments' => 'Investments', 'wills' => 'Wills', 'tax-planning' => 'Tax planning', 'life-insurance' => 'Life insurance', 'currency-exchange' => 'Currency exchange', 'retirement-planning' => 'Retirement planning', 'international-healthcare' => 'International healthcare', 'savings-plans' => 'Savings plans', 'education

how to pass id in controller from form action using codeigniter

隐身守侯 提交于 2019-12-08 09:37:42
问题 hey guys i am new in codeigniter,i have a form like this <form class="addinvestmentform" action="<?php echo base_url();?>index.php/ctl_dbcont/input_investment/$id" name="application" method="post" > //some code </form> i have a controller methode function input_investment($id) { $this->load->helper('form'); $this->load->helper('html'); $this->load->model('mod_user'); $this->mod_user->insertinvestment($id); } i want to get $id from form action to controller methode how can i do that . . pls

select box validation in Codeigniter

你。 提交于 2019-12-03 20:59:41
i am new to Codeigniter and I have some trouble in select box validation. I want default select value at beginning. <select name="schooGroups[]"> <option value="0">Select User Group</option> <option value="1">Admin</option> </select> how can i make it required field in form and display error message on select of zero "0" value. This will have the entry marked as "selected" as...selected by default. You want a multi-select dropdown, right? <select name="schoolGroups[]" multiple="multiple"> <option value="0" selected="selected">Select User Group</option> <option value="1">Admin</option> </select

Codeigniter - edit form (repopulating) with edit_unique

a 夏天 提交于 2019-12-02 03:41:29
问题 It seems that the edit_unique function, which is desribed here - Validating Uniqueness In CodeIgniter When Updating A Record, kills the set_value function. All works fine, which something like this... echo form_input('username', set_value('username',$user->username)); But when using the edit_unique validation, the value is empty after submitting the form. Post-Variables are ok and also the validation has no errors - but the value is not set. Any idea how I can fix that? 回答1: Ok - found it