Ok - I spent an hour on this - and I developed a problem + solution
, , , , CI , , "" ( ). "" 0 - .
$_POST (NOT $user_group_profiles), "", . . $_POST - $_POST, $user_group_profiles
, :
$user_group_profiles = $this->input->post('user_group_profiles', TRUE);
foreach ($user_group_profiles as $key => $user_group_profile)
{
$this->form_validation->set_rules($key."[profile_name]", "Profile Name", "trim|required");
$this->form_validation->set_rules($key."[birthdate]", "Birthdate", "trim|required");
$this->form_validation->set_rules($key."[height]", "Height", "trim|greater_than[0]");
$this->form_validation->set_rules($key."[weight]", "Weight", "trim|greater_than[0]");
if (empty($user_group_profile['height']))
{
unset($_POST[$key]['height']);
}
if (empty($user_group_profile['weight']))
{
unset($_POST[$key]['weight']);
}
}
- .
, $_POST:
foreach ($user_group_profiles as $key => $user_group_profile)
{
$this->form_validation->set_rules($key."[profile_name]", "Profile Name", "trim|required");
$this->form_validation->set_rules($key."[birthdate]", "Birthdate", "trim|required");
if ( ! empty($user_group_profile['height']))
{
$this->form_validation->set_rules($key."[height]", "Height", "trim|greater_than[0]");
}
if ( ! empty($user_group_profile['weight']))
{
$this->form_validation->set_rules($key."[weight]", "Weight", "trim|greater_than[0]");
}
}