Welcome Guest, Not a member yet? Register   Sign In
Inserting multiple form fields with same name
#3

[eluser]Dede[/eluser]
Thanks for fast reply skunkbad.

I've already tried that approach, and so far seems the best.
The only problem is that I'm using Jamie Rumbelow's CRUD model https://github.com/jamierumbelow/codeigniter-base-model which is implementing the following validation pattern: http://ellislab.com/codeigniter/user-gui...lesasarray.
And since I want to have dynamic number of room types, e.g. 5 sets for free user, 10 sets of room types for paid user, the validation rules should be defined dynamically as well.

For example, if the user has opened and filled 3 sets of room types, the validation rules for first set in Rumbelow's MY_Model should be:

Code:
protected $validate = array(
   array(
    'field' => 'room_types_1',
    'label' => 'room_types',
    'rules' => 'trim|required|xss_clean|min_lenght[3]'  
   ),
   array(
    'field' => 'room_types_mk_1',
    'label' => 'room_types',
    'rules' => 'trim|required|xss_clean|min_lenght[3]'
   ),
   array(
    'field' => 'max_occupancy_1',
    'label' => 'room_types',
    'rules' =>'trim|required|xss_clean|min_lenght[1]|max_length[2]'  
   ),
   array(
    'field' => 'extra_bedding_1',
    'label' => 'room_types',
    'rules' => 'trim|xss_clean|min_lenght[1]|max_length[2]'
   )  
);

But real problem occurs when the user, for example, has opened 5 sets of room types but filled only 3.
Then, instead of inserting only 3 sets, there will be validation error on other 2 since they are empty.

I guess I should switch to normal AC (without using MY_Model CRUD) for this form to avoid this problem and use you solution.


Messages In This Thread
Inserting multiple form fields with same name - by El Forum - 03-01-2012, 07:05 PM
Inserting multiple form fields with same name - by El Forum - 03-01-2012, 11:46 PM
Inserting multiple form fields with same name - by El Forum - 03-02-2012, 08:41 AM
Inserting multiple form fields with same name - by El Forum - 03-02-2012, 08:50 AM
Inserting multiple form fields with same name - by El Forum - 03-02-2012, 11:20 AM
Inserting multiple form fields with same name - by El Forum - 03-02-2012, 09:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB