• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Form validation and array-based form names

#1
[eluser]Unknown[/eluser]
Hi folks,

This is a question about form validation.

I am dynamically generating a list of existing users from the database so as to enable the admin to change their personal details.

I'm doing so with array-based form names so the code would look like this:

Code:
<label for="username2">Edit Cathy Brown</label>
&lt;input name="usernameEdit[2]" value="Cathy Brown" id="username2" maxlength="30" type="text"&gt;
<label for="email-2">Email:</label>
&lt;input name="emailEdit[2]" value="[email protected]" id="email-2" maxlength="50" type="text"&gt;

The number value, of course, corresponds to the user id in the database table

When I am submitting for form submission I could just check the values like so:

Code:
if(empty(implode($_POST['usernameEdit'])) {

echo "NOT EMPTY";

}

The above uses the implode function to covert the array to a string but what do I need to do so as the set_rules method can handle the input:

Code:
$this->form_validation->set_rules('usernameEdit', 'username','trim|required|max_length[30]');

It is giving me an error message that it is an array not a string


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.