Welcome Guest, Not a member yet? Register   Sign In
Jquery generated hidden form fields work fine but cause error in core.php file
#1

[eluser]Unknown[/eluser]
This is a strange error in the sense that everything works but php spits out an error anyway.

I'm using codeigniter 2.1.3 and twitter bootstrap, I have created a form with the bootstrap button groups to act as radio buttons, and the way I get the values from these is with a little jquery on the form submit.

Code:
$('#edit-profile-form').submit(function() {
  $('#edit-profile-form .btn.active').each(function() {
   var input = document.createElement("input");
   input.setAttribute("type", "hidden");
   input.setAttribute("name", this.name);
   input.setAttribute("value", this.value);
   document.getElementById("settings-edit-profile-form").appendChild(input);
  });
});

This will grab the 'name' and 'value' of the active button and create a hidden input tag for each one (3 in my case) so i can get the value via $this->input->post('gender') etc like any other field.

While I get the values fine and update the values in the database with no errors, the view is rendered with this:

A PHP Error was encountered
Severity: Warning
Message: in_array() expects parameter 2 to be array, null given
Filename: core/Input.php
Line Number: 588


There are 3 consecultive messages like this, 1 for each hidden input.

I'm too new to php (3 months - .NET programmer previously) to piece it all together as to why and not a fan of modifying core files as it would be me anyway I would say.

Can anyone help me figure this out?

EDIT: it turns out that if I only have 1 button group there is no error, so its slowly revealing itself...




Theme © iAndrew 2016 - Forum software by © MyBB