EllisLab text mark
Advanced Search
1 of 12
1
   
Who wants to test the new CI Form Validation class?
Posted: 26 August 2008 04:25 PM
Avatar
Joined: 2001-12-21
95 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.

 Signature 
 
Posted: 26 August 2008 05:08 PM   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-25
83 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.

 Signature 

My website: http://jamesgifford.com

 
Posted: 26 August 2008 05:41 PM   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2007-09-20
82 posts

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

 Signature 

PHP Rocks!

 
Posted: 26 August 2008 06:08 PM   [ # 3 ]   [ Rating: 0 ]
Joined: 2007-09-13
247 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 !!!

 Signature 

Sarfaraz Momin.
PHP With Us

 
Posted: 26 August 2008 06:33 PM   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2008-07-28
511 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?

 Signature 

~ 4 All the Right Reasons ~

 
Posted: 26 August 2008 06:39 PM   [ # 5 ]   [ Rating: 0 ]
Joined: 2006-10-17
207 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 smile

 
Posted: 26 August 2008 06:47 PM   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2006-06-16
319 posts

This is good news indeed. smile 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!

Sarfaraz Momin - 26 August 2008 10:08 PM

[...] 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. smile

drewbee - 26 August 2008 10:33 PM

[...] 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!

 Signature 

Best regards. Zacharias.
Matchbox (Modular Separation) | Wick (Controller Loader)

 
Posted: 26 August 2008 07:20 PM   [ # 7 ]   [ Rating: 0 ]
Joined: 2008-04-19
1153 posts

Nice smile

Now, I just have to download the latest….

 Signature 

Thorpe Obazee

 
Posted: 26 August 2008 07:56 PM   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2008-07-28
511 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?

 Signature 

~ 4 All the Right Reasons ~

 
Posted: 26 August 2008 07:56 PM   [ # 9 ]   [ Rating: 0 ]
Joined: 2007-11-08
237 posts

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

 Signature 

Redux Auth is no longer maintained.

 
Posted: 26 August 2008 08:00 PM   [ # 10 ]   [ Rating: 0 ]
Avatar
Joined: 2002-06-03
6510 posts
drewbee - 26 August 2008 11:56 PM

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

 Signature 
 
Posted: 26 August 2008 08:01 PM   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2001-12-21
95 posts
nmweb - 26 August 2008 10:39 PM

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.

 Signature 
 
Posted: 26 August 2008 08:21 PM   [ # 12 ]   [ Rating: 0 ]
Avatar
Joined: 2008-07-28
511 posts
Derek Jones - 27 August 2008 12:00 AM
drewbee - 26 August 2008 11:56 PM

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?

 Signature 

~ 4 All the Right Reasons ~

 
Posted: 26 August 2008 08:26 PM   [ # 13 ]   [ Rating: 0 ]
Avatar
Joined: 2002-06-03
6510 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 http://dev.ellislab.com/svn/CodeIgniter/trunk <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.

 Signature 
 
Posted: 26 August 2008 08:40 PM   [ # 14 ]   [ Rating: 0 ]
Avatar
Joined: 2006-07-27
2617 posts

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

 Signature 

Check out the Template Library
Oh yeah, I tweet, too (regarding CodeIgniter on occassion).

 
Posted: 26 August 2008 08:41 PM   [ # 15 ]   [ Rating: 0 ]
Avatar
Joined: 2008-07-28
511 posts

Thank you sir smile  Thanks with the help with subversion as well. All seems to be up and running well.

 Signature 

~ 4 All the Right Reasons ~

 
1 of 12
1