Welcome Guest, Not a member yet? Register   Sign In
validation problem
#1

[eluser]dimis[/eluser]
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?
#2

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

Code:
function form() {
  $this->load->library('validation');
  $this->validation->set_rules(array(
    'selectbox' => 'required|callback__check_setbox'));
  $this->validation->set_fields(array(
    '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;
}
#3

[eluser]Sumon[/eluser]
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
#4

[eluser]Mirage[/eluser]
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....

-m
#5

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

[eluser]Mirage[/eluser]
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.

Cheers
-m
#7

[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.)




Theme © iAndrew 2016 - Forum software by © MyBB