Welcome Guest, Not a member yet? Register   Sign In
[Solved] Form Validation Callback With Array "selected[]"
#1

(This post was last modified: 04-05-2015, 07:35 PM by wolfgang1983.)

I have a post array called selected on my form name="selected[]";  The set message does not work.


I am still unsure on how to use callbacks with array. I trying to understand it.

My callback message works fine with single post but not array[]


How can I make call back pick up name="selected[]"; and display message.


PHP Code:
public function delete() {
$this->form_validation->set_rules('selected[]''''callback_validateDelete');

if (
$this->form_validation->run($this) == FALSE) {

redirect('admin/user_group');

} else {

foreach (
$_POST['selected'] as $user_group_id) {
$this->delete_user_group($user_group_id);
}

$this->session->set_flashdata('success''Success: You have modified user groups!');
redirect('admin/user_group');
}
}

public function 
validateDelete() {

$this->load->library('user');

if (
$this->user->hasPermission('modify'"User_group_list")) {
return 
true;
} else {
$this->form_validation->set_message('validateDelete''Warning: You do not have permission to modify user groups');
return 
false;
}

There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
[Solved] Form Validation Callback With Array "selected[]" - by wolfgang1983 - 04-05-2015, 07:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB