ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Who wants to test the new CI Form Validation class?

August 26, 2008 4:25pm

Subscribe [29]
  • #1 / Aug 26, 2008 4:25pm

    Rick Ellis's avatar

    Rick Ellis

    107 posts

    Hi everyone!

    I wanted to mention that I added a new Form Validation library to our SVN repository. We plan to make it available in the next version of CI, but since this is a fairly substantial rewrite I thought it would be good to let people kick the tires before officially releasing it.

    Among the new features:

    - Simplified syntax.  The old version required users to set rules in one step, and set field names in another.  These two steps have been combined into one.

    - Array support.  The new class allows arrays to be used as field names.  It supports multidimensional arrays as deep as you need.  For example, you could call a field:  options[colors][websafe][]

    - Support for storing your rules in a config file so you can manage your rules in one place.  You can even organize your rules into groups of rules. These rules can be loaded as needed, and even assigned to specific controllers/functions and loaded automatically.

    - Added several helper functions so that your view files no longer need to use the validation object.


    If you decide to try the new library, please download the entire CI application from SVN (including the user guide), since a number of files have changes to support the new library.

  • #2 / Aug 26, 2008 5:08pm

    James Gifford's avatar

    James Gifford

    77 posts

    Excellent work!

    This looks like it will really help cleanup my controllers. I especially like the ability to use config files to store the validation rules.

    One thing I’ve found though: I can’t seem to get the validation_errors() function to output anything. When I use $this->form_validation->error_string() it works, but not with the helper function.

  • #3 / Aug 26, 2008 5:41pm

    imzyos's avatar

    imzyos

    79 posts

    nice job as always, some date to the next version?

  • #4 / Aug 26, 2008 6:08pm

    Sarfaraz Momin

    233 posts

    OMG !!! This gives the glimpses of what CI 2.0 is going to be. I think this rocks!!! great job guys !!! Already started using it in my current project.

    Keep up the good work !!!

  • #5 / Aug 26, 2008 6:33pm

    drewbee's avatar

    drewbee

    480 posts

    Thank You!! I know I couldn’t wait for the day when I could ‘de-extend’ the validation class because these exact things mentioned above. Its funny you should mention the setting rules & fields in one call, because I did that as well LOL.

    $this->validation->set_rules_fields($rules);

    The only thing I didn’t see you mention was about setting the default value for form postings. Any addition to this?

  • #6 / Aug 26, 2008 6:39pm

    nmweb

    206 posts

    Why stick to the singleton? There is now a helper in the view to retrieve the one instance of the validation object. What if I want more validation objects?  I can create more by instantiating them but not access them from the helpers since they rely on there being one validation object. Of course I can then use the use the methods like error() directly on the other instantiated objects but then I don’t see the point of having any helpers for the validation object at all. This all to not having the validation object in the view? Non-altering methods in the view are allowed in MVC

    Apart from that, nice job. The library could do with a little improvement 😊

  • #7 / Aug 26, 2008 6:47pm

    zdknudsen's avatar

    zdknudsen

    305 posts

    This is good news indeed. 😊 You’ve managed to cover pretty much all the flaws i felt the library had… except one. Like before, standard procedure seems to be using public methods for callback functions (at least that’s the example still given in the user guide), which makes them available through a browser. I just feel this is bad practice. Otherwise, thumbs up!

    [...] glimpses of what CI 2.0 is going to be. [...]

    As I understand it you should probably expect it to be more like CI 1.7, since it won’t be a major overhaul, but additions to libraries/helpers/etc. Also, you’re able to glimpse at the next version everytime ellislab commits their changes to the svn. 😊

    [...] The only thing I didn’t see you mention was about setting the default value for form postings. Any addition to this?

    The second parameter of the new helper function set_value() allows you to, wait for it, set a default value!

  • #8 / Aug 26, 2008 7:20pm

    Thorpe Obazee

    1138 posts

    Nice 😊

    Now, I just have to download the latest….

  • #9 / Aug 26, 2008 7:56pm

    drewbee's avatar

    drewbee

    480 posts

    Hmm. Ok. I FAIL at the SVN thing. I went to downloads > subversion, but it looks like the files are still the old ones?

  • #10 / Aug 26, 2008 7:56pm

    Popcorn

    225 posts

    Rick, sounds like a great addition. I will test it 😊

  • #11 / Aug 26, 2008 8:00pm

    Derek Jones's avatar

    Derek Jones

    7561 posts

    Hmm. Ok. I FAIL at the SVN thing. I went to downloads > subversion, but it looks like the files are still the old ones?

    You will have to do a checkout of http://dev.ellislab.com/svn/CodeIgniter/trunk/ drewbee

  • #12 / Aug 26, 2008 8:01pm

    Rick Ellis's avatar

    Rick Ellis

    107 posts

    There is now a helper in the view to retrieve the one instance of the validation object. What if I want more validation objects?  I can create more by instantiating them but not access them from the helpers since they rely on there being one validation object. Of course I can then use the use the methods like error() directly on the other instantiated objects

    I think you just answered your own question.  Most people will never need multiple simultaneous validation objects, so for those, there are helpers.

  • #13 / Aug 26, 2008 8:21pm

    drewbee's avatar

    drewbee

    480 posts

    Hmm. Ok. I FAIL at the SVN thing. I went to downloads > subversion, but it looks like the files are still the old ones?

    You will have to do a checkout of http://dev.ellislab.com/svn/CodeIgniter/trunk/ drewbee

    Hmm. Sorry. I have never done version’ing across servers before.

    So… as it stands now I managed to download everything onto a running copy of subversion on my pc. Thats pretty neat. lol. Guess I just gotta upload everything to my server now.

    One question about this validation class, is that it has a new name Form_Validation (why I didn’t see any changes in the file).

    Can we make any assumptions about this, as in it will eventually overtake the old Validation class, or will the old validation class be phased out, or will they both run parallel with each other?

  • #14 / Aug 26, 2008 8:26pm

    Derek Jones's avatar

    Derek Jones

    7561 posts

    If you’re uploading to a remote server, you’ll want to do an export from the SVN first, so you aren’t uploading hundreds of svn files that contain the revision information.

    svn export <a href="http://dev.ellislab.com/svn/CodeIgniter/trunk">http://dev.ellislab.com/svn/CodeIgniter/trunk</a> <target>

    The old Validation class will eventually be phased out, but it’s included so that backwards compatibility can be maintained for enough time for developers to make the switch to the new class at a more leisurely pace.

  • #15 / Aug 26, 2008 8:40pm

    Colin Williams's avatar

    Colin Williams

    2601 posts

    Good stuff. Might play around with it tonight and post some feedback.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases