Using Arrays as Field Names - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Using Arrays as Field Names (/showthread.php?tid=30887) |
Using Arrays as Field Names - El Forum - 06-20-2010 [eluser]moleculezz[/eluser] That's much nicer. Thanks a lot for your help!! Using Arrays as Field Names - El Forum - 08-02-2010 [eluser]bkirkman[/eluser] I found the following bug report that helped solve this issue for me. Arrays as field names not working Thanks, zdknudsen! Worked like a charm. I didn't have anything to do with it, but maybe this will help someone save some time and frustration in the future. Using Arrays as Field Names - El Forum - 09-10-2010 [eluser]webdevguy[/eluser] Can someone please post some working code. I'm going out of my mind trying to solve this problem that at least two people have solved here. Also, the link for the bug tracker with it's solution is a dead link. I keep getting either the word 'Array' or blanks in my input fields on return from the server with invalid data. Using Arrays as Field Names - El Forum - 09-13-2010 [eluser]bkirkman[/eluser] Since the above link is dead, here's the fix that worked for me. I take no credit. It was posted in the bug fix. This is what the set_value function should look like. It can be modified in the Form_validation library, but it is recommended to override it in the custom project library MY_Form_validation. Here goes. Code: function set_value($field = '', $default = '') Hope this helps. Using Arrays as Field Names - El Forum - 09-13-2010 [eluser]bkirkman[/eluser] To expound on the revision above, the following is the way I have set up the controller and the view. Set up validation in the controller as follows. Controller: Code: ... Then in the view, I chose to dynamically set the field values depending on the existing condition. I suppose there's a more elegant way to refactor this code, but I, too, spent a lot of time pulling my hair out. I was just happy with a solution. View: Code: ... I'm not sure exactly how others are implementing this "feature." I'm using javascript to add blank fields to the form if the user needs to input more data. That's a discussion for another time. Also, writing the post data back to the database is not exactly trivial when dealing with edits and deletions. Perhaps that will also be a post for another time. Maybe a wiki is in order for forms such as this. Using Arrays as Field Names - El Forum - 10-13-2010 [eluser]thomasp[/eluser] With the fix posted above, default value does not apply when postdata is NULL. So, a best fix for this issue seem to be : Code: function set_value($field = '', $default = '') { Using Arrays as Field Names - El Forum - 11-25-2010 [eluser]webdevguy[/eluser] I just posted my solution to this problem on my blog at Expandable Input Block In CodeIgniter. It has a working demo and has the ability for useragents to return at a later date and update their entries. I used really basic JavaScript validation in addition to CodeIgniter's validation since CI's error messages were not showing up inline (an absolute necessity in this case since the form could get very long if the users decided to add, say, 50 input blocks). If someone wants to refactor my JQuery into a plug-in and/or improve the front-end validation I would be grateful. Using Arrays as Field Names - El Forum - 11-25-2010 [eluser]helenth01[/eluser] This conversation is going no where. It’s lacking the place of a good leader to head the things to come out on conclusion. ====================== PLR Private Label Rights Using Arrays as Field Names - El Forum - 11-25-2010 [eluser]helenth01[/eluser] Well, it’s amazing. The miracle has been done. Well done. ====================== [url="http://www.plrprivatelabelrights.com" rel="dofollow"]PLR Private Label Rights[/url] Using Arrays as Field Names - El Forum - 04-28-2011 [eluser]Ninjabear[/eluser] [quote author="webdevguy" date="1290703879"]I just posted my solution to this problem on my blog at Expandable Input Block In CodeIgniter. It has a working demo and has the ability for useragents to return at a later date and update their entries. I used really basic JavaScript validation in addition to CodeIgniter's validation since CI's error messages were not showing up inline (an absolute necessity in this case since the form could get very long if the users decided to add, say, 50 input blocks). If someone wants to refactor my JQuery into a plug-in and/or improve the front-end validation I would be grateful.[/quote] It's funny you should write this actually. I needed this exact thing for Jquery when I built my site a few months ago (www.fixilink.com). I'll definitely have a look at your solution as well, could be simpiler. I ended up with this piece of code: Code: $(function() Incidentally I never had to extend any libraries as you did and CI picks up the additional info here just fine. However I am just using a single form validation error at the top of the screen for a maximum of five fields. |