|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Display validation error messages next to each field?I'm struggling with displaying error messages next to each field, insted of at the top or bottom of the form. Is there an example somewhere?
I'm looking for something like this, which I could insert into a looping structure: $f->errors->find('fieldname'); --steve -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Steve Piercy Web Site Builder Soquel, CA <web@...> <http://www.StevePiercy.com/> -- ############################################################# This message is sent to you because you are subscribed to the mailing list <knop@...>. To unsubscribe, E-mail to: <knop-off@...> Send administrative queries to <knop-request@...> List archive http://www.nabble.com/Knop-Framework-Discussion-f29076.html Project homepage http://montania.se/projects/knop/ Google Code has the latest downloads at http://code.google.com/p/knop/ |
|
|
Re: Display validation error messages next to each field?On Wednesday, June 24, 2009, Web@... (Steve Piercy - Web Site Builder) pronounced:
>I'm struggling with displaying error messages next to each field, insted of at the >top or bottom of the form. Is there an example somewhere? > >I'm looking for something like this, which I could insert into a looping structure: > >$f->errors->find('fieldname'); Found it: knop_form -> keys // was the key! hahaha loop(-from=1,-to=10); '<p>'$f -> renderform(-from=loop_count, -to=loop_count); loop_count < 10 ? '<span class="required">*</span>'; if($f -> errors -> find($f->keys->get(loop_count))->size > 0); '<span class="error_message"> '; iterate($f -> errors -> find($f->keys->get(loop_count)),local('i')); if(#i -> isa('pair')); // display custom knop error messages if(#i -> second -> isa('integer')); // by extending the language type and using an error code and message $f -> error_msg(-error_code=#i -> value); else; // by using a custom string for the error message #i -> value; /if; else; // display default knop error messages (required) ' Must not be empty'; /if; /iterate; '</span>'; /if; '</p>'; /loop; Which renders as the attached screenshot (hope it comes through). Note: Since I'm using some custom validation, I cannot use Knop's builtin -required parameter for the rendering template on these fields, so I have to do some janky code workaround. --steve -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Steve Piercy Web Site Builder Soquel, CA <web@...> <http://www.StevePiercy.com/> -- ############################################################# This message is sent to you because you are subscribed to the mailing list <knop@...>. To unsubscribe, E-mail to: <knop-off@...> Send administrative queries to <knop-request@...> List archive http://www.nabble.com/Knop-Framework-Discussion-f29076.html Project homepage http://montania.se/projects/knop/ Google Code has the latest downloads at http://code.google.com/p/knop/ |
|
|
Re: Display validation error messages next to each field?Have you looked at the new -validate option again? It's very powerful and provides a flexible error message mechanism.
You might recall the discussion about this back in March http://www.nabble.com/Validation-td22675499.html At 04.48 -0700 2009-06-24, Steve Piercy - Web Site Builder wrote: >I'm struggling with displaying error messages next to each field, insted of at the top or bottom of the form. Is there an example somewhere? > >I'm looking for something like this, which I could insert into a looping structure: > >$f->errors->find('fieldname'); > >--steve > >-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- >Steve Piercy Web Site Builder Soquel, CA ><web@...> <http://www.StevePiercy.com/> > >-- >############################################################# >This message is sent to you because you are subscribed to >the mailing list <knop@...>. >To unsubscribe, E-mail to: <knop-off@...> >Send administrative queries to <knop-request@...> >List archive http://www.nabble.com/Knop-Framework-Discussion-f29076.html >Project homepage http://montania.se/projects/knop/ >Google Code has the latest downloads at http://code.google.com/p/knop/ -- Johan Sölve [FSA Member, Lasso Partner] Web Application/Lasso/FileMaker Developer MONTANIA SOFTWARE & SOLUTIONS http://www.montania.se mailto:joh-n@... (spam-safe email address, replace '-' with 'a') -- ############################################################# This message is sent to you because you are subscribed to the mailing list <knop@...>. To unsubscribe, E-mail to: <knop-off@...> Send administrative queries to <knop-request@...> List archive http://www.nabble.com/Knop-Framework-Discussion-f29076.html Project homepage http://montania.se/projects/knop/ Google Code has the latest downloads at http://code.google.com/p/knop/ |
|
|
Re: Display validation error messages next to each field?I actually worked out a solution, not very elegant, but it works. The solution was based on the previous discussion in March and April. However that discussion did not cover the display of error messages next to each field, but only in a single clump either before or after the form.
If there is a better solution than this one, then I'm all for it: http://www.nabble.com/attachment/24184440/0/_inline_errors.png http://www.nabble.com/Re%3A-Display-validation-error-messages-next-to-each-field--p24184440.html --steve On Wednesday, June 24, 2009, inbox_js@... (Johan Solve) pronounced: >Have you looked at the new -validate option again? It's very powerful and provides a >flexible error message mechanism. >You might recall the discussion about this back in March >http://www.nabble.com/Validation-td22675499.html > > > >At 04.48 -0700 2009-06-24, Steve Piercy - Web Site Builder wrote: >>I'm struggling with displaying error messages next to each field, insted of at the >top or bottom of the form. Is there an example somewhere? >> >>I'm looking for something like this, which I could insert into a looping structure: >> >>$f->errors->find('fieldname'); >> >>--steve >> >>-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- >>Steve Piercy Web Site Builder Soquel, CA >><web@...> <http://www.StevePiercy.com/> >> >>-- >>############################################################# >>This message is sent to you because you are subscribed to >>the mailing list <knop@...>. >>To unsubscribe, E-mail to: <knop-off@...> >>Send administrative queries to <knop-request@...> >>List archive http://www.nabble.com/Knop-Framework-Discussion-f29076.html >>Project homepage http://montania.se/projects/knop/ >>Google Code has the latest downloads at http://code.google.com/p/knop/ > > >-- > Johan Sölve [FSA Member, Lasso Partner] > Web Application/Lasso/FileMaker Developer > MONTANIA SOFTWARE & SOLUTIONS >http://www.montania.se mailto:joh-n@... > (spam-safe email address, replace '-' with 'a') > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Steve Piercy Web Site Builder Soquel, CA <web@...> <http://www.StevePiercy.com/> -- ############################################################# This message is sent to you because you are subscribed to the mailing list <knop@...>. To unsubscribe, E-mail to: <knop-off@...> Send administrative queries to <knop-request@...> List archive http://www.nabble.com/Knop-Framework-Discussion-f29076.html Project homepage http://montania.se/projects/knop/ Google Code has the latest downloads at http://code.google.com/p/knop/ |
|
|
Re: Display validation error messages next to each field?On Wednesday, June 24, 2009, Web@... (Steve Piercy - Web Site Builder) pronounced:
>I'm struggling with displaying error messages next to each field, insted of at the >top or bottom of the form. Is there an example somewhere? I've modified this slightly such that I can now insert many error messages into an array, then display each message in a list. The display checks for default Knop error messages, extended language types with error codes and messages, or simple custom strings. See attached screenshot for example. Just another example of how nifty Knop is. cfg_file.inc ---------------------------- $f -> error_lang -> insert(-language='en', -key=9001, -value='Must contain letters or numbers only.'); $f -> error_lang -> insert(-language='en', -key=9002, -value='Must be at least 8 characters in length.'); var('v_username'={ local('result'=array); // when size is evaluated, if 0 then it is okay if(params -> size < 1); #result ->insert('Must not be empty.'); /if; if(string_findregexp(params, -find='[^a-zA-Z0-9]')); #result ->insert(9001); /if; if(params -> size < 8); #result ->insert(9002); /if; #result->size==0 ? #result = 0; return(#result); } ); $f -> addfield(-name='username', -label=$lang_ui -> username, -type='text',-validate=$v_username, -focus); cnt_file.inc ---------------------------- // janky method to display error messages inline with each field loop(-from=1,-to=4); '<p>'$f -> renderform(-from=loop_count, -to=loop_count); // exclude the submit button from having a * at the end loop_count < 4 ? '<span class="required">*</span>'; if($f -> errors -> find($f->keys->get(loop_count))->size > 0); // we gots errors! oh noez! '<span class="error_message"> '; iterate($f -> errors -> find($f->keys->get(loop_count)),local('i')); if(#i -> isa('pair')); // display custom knop error messages iterate((#i -> second),local('j')); if(#j -> isa('integer')); // by extending the language type and using an error code and message $f -> error_msg(-error_code=#j) + '<br />'; else; // by using a custom string for the error message #j + '<br />'; /if; /iterate; else; // display default knop error messages ("required") ' Must not be empty.<br />'; /if; /iterate; '</span>'; /if; '</p>'; /loop; --steve -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Steve Piercy Web Site Builder Soquel, CA <web@...> <http://www.StevePiercy.com/> -- ############################################################# This message is sent to you because you are subscribed to the mailing list <knop@...>. To unsubscribe, E-mail to: <knop-off@...> Send administrative queries to <knop-request@...> List archive http://www.nabble.com/Knop-Framework-Discussion-f29076.html Project homepage http://montania.se/projects/knop/ Google Code has the latest downloads at http://code.google.com/p/knop/ |
|
|
Re: Display validation error messages next to each field?A better way to display errors inline is definitely needed.
At 07.56 -0700 2009-06-25, Steve Piercy - Web Site Builder wrote: >On Wednesday, June 24, 2009, Web@... (Steve Piercy - Web Site Builder) pronounced: > >>I'm struggling with displaying error messages next to each field, insted of at the >>top or bottom of the form. Is there an example somewhere? > >I've modified this slightly such that I can now insert many error messages into an array, then display each message in a list. The display checks for default Knop error messages, extended language types with error codes and messages, or simple custom strings. > >See attached screenshot for example. > >Just another example of how nifty Knop is. > >cfg_file.inc >---------------------------- >$f -> error_lang -> insert(-language='en', -key=9001, -value='Must contain letters or numbers only.'); >$f -> error_lang -> insert(-language='en', -key=9002, -value='Must be at least 8 characters in length.'); > >var('v_username'={ > local('result'=array); // when size is evaluated, if 0 then it is okay > if(params -> size < 1); > #result ->insert('Must not be empty.'); > /if; > if(string_findregexp(params, -find='[^a-zA-Z0-9]')); > #result ->insert(9001); > /if; > if(params -> size < 8); > #result ->insert(9002); > /if; > #result->size==0 ? #result = 0; > return(#result); >} >); > >$f -> addfield(-name='username', -label=$lang_ui -> username, -type='text',-validate=$v_username, -focus); > > >cnt_file.inc >---------------------------- >// janky method to display error messages inline with each field >loop(-from=1,-to=4); > '<p>'$f -> renderform(-from=loop_count, -to=loop_count); > // exclude the submit button from having a * at the end > loop_count < 4 ? '<span class="required">*</span>'; > if($f -> errors -> find($f->keys->get(loop_count))->size > 0); > // we gots errors! oh noez! > '<span class="error_message"> '; > iterate($f -> errors -> find($f->keys->get(loop_count)),local('i')); > if(#i -> isa('pair')); > // display custom knop error messages > iterate((#i -> second),local('j')); > if(#j -> isa('integer')); > // by extending the language type and using an error code and message > $f -> error_msg(-error_code=#j) + '<br />'; > else; > // by using a custom string for the error message > #j + '<br />'; > /if; > /iterate; > else; > // display default knop error messages ("required") > ' Must not be empty.<br />'; > /if; > /iterate; > '</span>'; > /if; > '</p>'; >/loop; > >--steve > >-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- >Steve Piercy Web Site Builder Soquel, CA ><web@...> <http://www.StevePiercy.com/> >Attachment converted: MacBook:_errors_array.png (PNGf/prvw) (013A156D) >-- >############################################################# >This message is sent to you because you are subscribed to >the mailing list <knop@...>. >To unsubscribe, E-mail to: <knop-off@...> >Send administrative queries to <knop-request@...> >List archive http://www.nabble.com/Knop-Framework-Discussion-f29076.html >Project homepage http://montania.se/projects/knop/ >Google Code has the latest downloads at http://code.google.com/p/knop/ -- Johan Sölve [FSA Member, Lasso Partner] Web Application/Lasso/FileMaker Developer MONTANIA SOFTWARE & SOLUTIONS http://www.montania.se mailto:joh-n@... (spam-safe email address, replace '-' with 'a') -- ############################################################# This message is sent to you because you are subscribed to the mailing list <knop@...>. To unsubscribe, E-mail to: <knop-off@...> Send administrative queries to <knop-request@...> List archive http://www.nabble.com/Knop-Framework-Discussion-f29076.html Project homepage http://montania.se/projects/knop/ Google Code has the latest downloads at http://code.google.com/p/knop/ |
| Free embeddable forum powered by Nabble | Forum Help |