Welcome Guest, Not a member yet? Register   Sign In
form_validation library and discrete functions ?
#1

[eluser]Monarobase[/eluser]
Hello,

I'm sorry if there is a very simple answer to this one but I have read the docs, searched the wiki and searched the forum so I am positing my question here.

I'm building a dynamic form which builds a form from database entries, I have made views per type of form input and am now working on the validation.

My database contains collomns like :

'required' => 0 or 1
'min' => 0 (deactivated) or 1 to 99999
'max' => 0(deactivated) or 1 to 999999

I could easily build the rules lines and run something like this for each line :

Code:
if($db->required == 1) $rules .= ($rules == '') ? 'required' : '|required';
if($db->min > 0) $rules .= ($rules == '') ? 'min_length['.$db->min.']' : '|min_length['.$db->min.']';
if($db->max > 0) $rules .= ($rules == '') ? 'max_length['.$db->max.']' : '|max_length['.$db->max.']';
$this->form_validation->set_rules($v->name, $v->descr, $rules);

However the docs mention discrete functions, but I have not managed to get them to work ...

This is what I have tried :

Code:
$this->form_validation->set_rules($v->name, $v->descr);
if($db->required == 1) $this->form_validation->required($v->name);
if($db->min > 0) $this->form_validation->min_length($v->name, $db->min);
if($db->max > 0) $this->form_validation->max_length($v->name, $db->max);

It seems that it doesn't work like the database library though as the discrete functions are not taken into account.

As you can see I have got my code working and it's more out of interest, but how are you supposed to use the "discrete" functions that the doc talks about here :

http://codeigniter.in.th/user_guide/libr...ereference

?

Thanks in advance


Messages In This Thread
form_validation library and discrete functions ? - by El Forum - 05-07-2010, 09:42 AM
form_validation library and discrete functions ? - by El Forum - 05-07-2010, 10:39 AM
form_validation library and discrete functions ? - by El Forum - 05-07-2010, 11:06 AM
form_validation library and discrete functions ? - by El Forum - 05-07-2010, 11:21 AM
form_validation library and discrete functions ? - by El Forum - 05-07-2010, 11:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB