Advanced Validation with Lithium PHP Framework -



Advanced Validation with Lithium PHP Framework -

i'm building pretty complex , dynamic form via lithium php framework.

i've got form working , saving mongodb little problem. having problem validation.

simple validations (such checking if field not empty or numeric) working fine. have few complex validations rely on number of fields in form.

for example, have form user can come in question , come in unlimited number of possible answers question. field id each reply listed such "answer_1", "answer_2", "answer_3", etc. user can add together unlimited number of answers. happens via fancy javascript inserts elements form on client side.

at validation level, want create sure every reply added not null.

i using "traditional" validator functionality built within lithium. doing @ model level, not controller level (note - have workaround solve on controller level, rather "right" way @ model)

the problem, far can tell, can pass single value validator rule. need pass values in form validator. if that, golden. pseudo-code i'm looking looks this:

validator::add('correcttest', function(&$value, $format = null, array $options = array()) { foreach ($_data $key => $value) { if (stristr($key, "answer_")) { if ($value == "") { homecoming false; } } } homecoming true; });

this code doesn't work, because $_data value not present. if figure out way fully-populated "$_data" object validator function, think work.

thanks in advance help

take @ what's within $options. should have 'values' key in there has of values form.

so seek $_data = $options['values'];

validation lithium

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -