• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
validation problem

I want to use the validation library.
I have a <select> input and I want this not to have the value '-1', what I can do?

[eluser]Michael Wales[/eluser]
My first thought, with a <select> input is... don't put -1 within the <option>s - but, just to answer your question.

function form() {
    'selectbox' => 'required|callback__check_setbox'));
    'selectbox' => 'Your select box'));

function _check_setbox($val) {
  if ((int) $val >= 0) {
    return TRUE;
  $this->validation->set_message('_check_setbox', 'Your setbox must be greater than -1.');
  return FALSE;

Is there are any validation like positive_value. I think currently CI don't have it. But this might be nice to have validation with positive_value, negative_value, zero_value.

Might be a request to add tiny feature to CI as well. Wink

Using ExtJs quite frequently, I've been dabbling with the thought of creating a core lib extension for the Validation class which supports 'validators'. Using the adapter pattern, this would provide a basis for extensible validation....


[eluser]Colin Williams[/eluser]
Put me on your notification list, Mirage. I'd like to see what you're thinking about.

I'll try to remember that. Most likely you'd read about here anyways.

I first need to look into Ricks beta announcement of the library and how he's adjusted it.

If I do write something, it'd likely be a core extension that provides transparent access to the Zend_Validation Library. I'm more and more growing fond of binding ZF functionality via CI Libraries. One could argue this being pointless as one could then just use ZF directly. The point for me however is to keep with the harmony of 'default' intelligence and config-driven approach of CI. This gives you added power CI style with minimal effort.


[eluser]Michael Wales[/eluser]
Check the Wiki as well - I believe xwero (I may have the name wrong) submitted an extended Validation class with a lot of great additions (greater_than, less_than, etc.)

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.