Home > CodeIgniter, Computing, Programming, php > Adding a second argument to CI form_validation callbacks

Adding a second argument to CI form_validation callbacks

About a month ago I started working with the CodeIgniter framework. It’s the first framework I have worked with and frankly, I love it!

So I was looking to add a second parameter to a form_validation callback. Here’s what I found:

$this->form_validation('user_name', 'name', "callback_test_name[$param2]");

and the callback:

test_name($name, $param2){
    ..// some logic to return

The form_validation class uses the form value as the first parameter, and you can pass the second parameter in the arguments as you would with any other rule references. (First snippet)

At first I was calling 2 validations. First the standard type of validation, then another validation on the same input. * BAD IDEA *

There were some issues with order of operations. I found it best to chain the whole lot together. Like so:

$this->form_validation('user_name', 'name', "required|min_length[10]|callback_test_name[$param2]");

I hope that helps anybody with the same question.

  1. November 7th, 2012 at 00:31 | #1

    Sculpting in time, but found the dry sorrow. That year, I remember this sentence: it is called time, remember
    to bring once sad. As the years passed, frozen fell in love sob intermittently. A little rain of fireworks, to conceal
    the lovesick self overflow. Don’t be silly, doomed the sigh leisurely.

  2. November 7th, 2012 at 06:01 | #2

    Currently often the concern could crop up this the reason complete ought to get such a solution? They say very simple that is certainly these kind of Wenger Wristwatches usually are robust and may also last longer in the event looked after in a very proper way.

  3. February 12th, 2013 at 20:30 | #3

    Do this come similar using php?

  4. March 2nd, 2013 at 09:08 | #4

    the subject that you wrote is very interesting and helpful

  5. March 2nd, 2013 at 09:09 | #5

    this is a very good post.Great and helpful blog

  6. March 2nd, 2013 at 09:11 | #6

    this is a very nice and helpful information. super b blog

  7. March 2nd, 2013 at 09:12 | #7

    i like your writing very much. i am impressed from your content

  8. March 13th, 2013 at 04:34 | #8

    If you doubt yourself , then indeed you stand on shaky11 ground .

  9. May 4th, 2013 at 04:14 | #9

    Thanks for taking the time to talk about this, I’m fervently about this and I appreciate studying this topic. Please, while you gain information, please update this web site with increased information. I’ve found it very helpful. There must be charging stations everywhere.

  10. robert
    June 7th, 2013 at 08:20 | #10

    Thanks for sharing helpful information, best term paper I really like your all post. I will bookmark your blog for future updates.

  11. July 13th, 2013 at 05:30 | #11

    the text you wrote is very interesting and i am impressed with the way you write. many congratulations

  12. July 29th, 2013 at 13:50 | #12

    i like your blog very much. it has interesting and useful articles

  13. November 18th, 2013 at 00:00 | #13

    it is useful and what you all have to share interesting. yepi 2 | friv 3

  14. December 12th, 2013 at 21:33 | #14

    These parameters are very useful indeed. I would never try to do as you think. Thanks for this useful information

  15. December 27th, 2013 at 22:04 | #15

    You really make it seem so easy with your presentation but I find this matter to be really something that I think I would never understand. It seems too complicated and extremely broad for me. I’m looking forward for your next post, I will try to get the hang of it!

  16. December 27th, 2013 at 22:05 | #16

    I had been trying to find getting published, and located your internet site. Great blog. Very inspirational! This website have this sort of nice information. Links are extremely helpful and and impressive too.

  17. January 3rd, 2014 at 04:53 | #17

    I definitely bookmark this page and share it with your friends, hopefully will be useful to them.

  18. March 10th, 2014 at 02:38 | #18

    It’s important also to look at the color and condition of the wood. Wood darkens and shrinks as it ages. Thin panels used as door inserts and drawer bottoms shrink faster than the thicker frames that support them. This shrinkage causes splits or cracks in panels that were nailed to the frame. Panels that were loosely held in place may no longer cover the full space of the frame. Where this is the case, the exposed edge should be slightly lighter in color than the rest of the wood composing the furniture.

  19. March 14th, 2014 at 04:42 | #19

    thanks for share, i like it. Friv 5

  20. March 29th, 2014 at 04:32 | #20

    We can understand and grasp the content in here.

  21. dastyn
    April 18th, 2014 at 13:04 | #21

    Please, while you gain information, please update juegos de
    tragaperras .

  22. dastyn
    April 18th, 2014 at 13:06 | #22

    I definitely bookmark this page and share it with your friends, hopefully will be useful to them.
    tragamonedas .

  23. May 27th, 2014 at 02:50 | #23

    Your topic is very useful to share.

  24. June 27th, 2014 at 03:30 | #24

    Studies show that green plants are good for workplaces where people perform creative tasks but bad where the work is more monotone.
    friv 2

  25. July 9th, 2014 at 01:37 | #25

    What a great initiative here. I’ll look around the site and see if I can offer any additional ideas. Thanks.

  26. July 12th, 2014 at 03:53 | #26

    hope you will share so much more to me more useful information and better, thanks
    Friv 6

  27. August 8th, 2014 at 08:18 | #27

    useful information. thank you for sharing articles were always new things

  28. Jame
    August 11th, 2014 at 17:47 | #28

    good code


  29. y9
    August 30th, 2014 at 22:04 | #29

    I love to read this type of material Good and attractive information I take from it..Thank you for posting such a good article.

  30. no name
    October 16th, 2014 at 09:19 | #30

    The article you have shared here very awesome. I really like and appreciated your work. I read deeply your article, the points you have mentioned in this article are useful. I must try to follow these points and also share others.

  31. April 4th, 2015 at 07:27 | #31

    Unfortunately,CI validation callbacks you are actuality held enslaved by yet one more MAC port. The dangerous, pervasive Adobe Reader which imply to have its puff tentacle into everything..

  32. April 20th, 2015 at 03:10 | #32

    great article, I was very impressed about it, wish you would have stayed next share

  33. May 6th, 2015 at 07:43 | #33

    Posts shared useful information and meaningful life, I’m glad to be reading this article and hope to soon learn the next article. thank you

  34. May 21st, 2015 at 04:28 | #34

    really nice

  35. Paulette dodson
    May 21st, 2015 at 04:29 | #35

    what you think about game of thrones? pay someone to do your assignment

  36. lesbian speed dating london
    May 21st, 2015 at 21:38 | #36

    I have been surfing on-line more than three hours lately, but I by no means found any fascinating article like yours. It is pretty price enough for me. In my view, if all website owners and bloggers made excellent content material as you probably did, the net might be much more useful than ever before.|

  37. leather laptop bags for men
    May 22nd, 2015 at 08:18 | #37

    Hello, I think your website might be having browser compatibility issues. When I look at your website in Opera, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, superb blog!|

  38. best seo company
    May 22nd, 2015 at 12:09 | #38

    Everything is very open with a precise description of the challenges. It was definitely informative. Your site is very useful. Thank you for sharing!|

  39. completely free sex dating site
    May 22nd, 2015 at 23:16 | #39

    If you are going for best contents like me, only pay a quick visit this web site all the time since it presents feature contents, thanks|

  40. wilson leather wallets for men
    May 23rd, 2015 at 11:04 | #40

    Can you tell us more about this? I’d like to find out more details.|

  41. buy a car with no credit
    May 23rd, 2015 at 20:47 | #41

    Saved as a favorite, I like your website!|

  42. mature dating review
    May 24th, 2015 at 01:12 | #42

    You’re so cool! I don’t suppose I’ve read a single thing like that before. So great to discover someone with some original thoughts on this topic. Really.. many thanks for starting this up. This web site is something that is required on the web, someone with a little originality!|

  43. seo companies
    May 24th, 2015 at 09:28 | #43

    Hey! This is my 1st comment here so I just wanted to give a quick shout out and say I really enjoy reading through your posts. Can you recommend any other blogs/websites/forums that go over the same topics? Thank you so much!|

  44. best travel duffel bag
    May 26th, 2015 at 05:30 | #44

    Hello there! Do you know if they make any plugins to protect against hackers? I’m kinda paranoid about losing everything I’ve worked hard on. Any recommendations?|

  45. briefcase bag
    May 26th, 2015 at 12:48 | #45

    Please let me know if you’re looking for a article writer for your weblog. You have some really great posts and I believe I would be a good asset. If you ever want to take some of the load off, I’d absolutely love to write some content for your blog in exchange for a link back to mine. Please send me an e-mail if interested. Cheers!|

  46. search engine optimization
    May 27th, 2015 at 06:02 | #46

    Ahaa, its nice conversation regarding this post at this place at this blog, I have read all that, so at this time me also commenting here.|

  47. womens briefcase tote
    May 27th, 2015 at 11:55 | #47

    Hi my family member! I wish to say that this article is amazing, nice written and include almost all important infos. I would like to peer extra posts like this .|

  48. group term life insurance
    May 28th, 2015 at 00:29 | #48

    Hello, i think that i saw you visited my weblog thus i came to “return the favor”.I am attempting to find things to enhance my web site!I suppose its ok to use some of your ideas!!|

  49. seo company
    May 29th, 2015 at 04:29 | #49

    Hello there, I discovered your blog via Google while searching for a related topic, your site came up, it appears to be like good. I have bookmarked it in my google bookmarks.

  1. No trackbacks yet.