Welcome Guest, Not a member yet? Register   Sign In
form_validation with array field
#1

[eluser]kaejiavo[/eluser]
Hi,

i have a problem validating an array field.
Code:
$this->form_validation->set_rules('qty[]', 'quantity', 'required');

  foreach ($items as $item) {
    // input field qty[]
    $quantity = array(
        'name' => "qty[{$item->id}]",
    'id' => 'quantity',
    'value' => set_value("qty[{$item->id}]"),
    'maxlength' => '5',
    'size' => '5',
    'style' => '',
    );
    $this->data['form']['quantity'][$item->id] = form_input($quantity);
  }

I get the form fields and the POST array as desired.
Code:
$_POST['qty']      
Array
(
    [3] => 4
    [1] =>
)

My Problem is that it will validate only if _all_ array values are set. I need only at least 1 value set for the application.
Has someone a clue for me how to validate this?

TIA
Marco
#2

[eluser]coffeeandcode[/eluser]
This is exactly the issue I'm dealing with here. You might want to follow that thread as well.




Theme © iAndrew 2016 - Forum software by © MyBB