Possible Bug with Radio Not Remaining Selected?

View: New views
4 Messages — Rating Filter:   Alert me  

Possible Bug with Radio Not Remaining Selected?

by Steve Piercy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Can someone confirm whether a bug exists in Knop when processing
radio button options that contain a comma (,)?

$f -> addfield(-name='radio1',
-options=array('a,b,c','d,e,f','g,h,i'), -label='testing',
-type='radio', -required);
$f -> addfield(-name='text1', -label='testing text',
-type='text', -required);

To trigger the bug, select a radio option, but leave text1
blank, then submit the form.  There should be an error due to a
missing required value.  However, the radio does not remain selected.

Next try replacing the commas with '-', and repeat.

$f -> addfield(-name='radio1',
-options=array('a-b-c','d-e-f','g-h-i'), -label='testing',
-type='radio', -required);

Here's a basic test case that runs off the Knop demo:

act_foo.inc
----------------
$f -> loadfields;
if(!($f -> isvalid) || $f -> error_code);
     // remain on the same path to show form again
     $nav -> (setlocation: ($nav -> actionpath));
     // show error message
     $message -> insert(($f -> error_msg) + ' ' + ($f -> error_code));
/if;


cfg_foo.inc
----------------
var: 'f'=(knop_form:
             -formaction=($nav -> url), // real URL path
             -method='post',
             -actionpath=($nav -> path);

$f -> addfield(-name='radio1',
-options=array('a-b-c','d-e-f','g-h-i'), -label='testing',
-type='radio', -required);
$f -> addfield(-name='text1', -label='testing text',
-type='text', -required);
$f -> (addfield: -name='button_login', -type='submit',
-value=$lang_ui -> login);


cnt_foo.inc
----------------
[$f->renderform]

I see a two instances of a suspect in Knop's form.inc:

     else: #fieldvalue_array >> ','; // Other database with
multiple checked
         #fieldvalue_array = #fieldvalue_array -> (split: ',');

--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: Possible Bug with Radio Not Remaining Selected?

by Johan Solve-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Multi values (like multiple checkboxes) are stored in MySQL as comma separated values (this is how Lasso does it and this is how Knop handles values for checkboxes, multi selects and radios). This is what you've run into. I'll look closer at the issue later today.


At 09.48 -0700 2009-09-21, Steve Piercy - Web Site Builder wrote:

>Can someone confirm whether a bug exists in Knop when processing radio button options that contain a comma (,)?
>
>$f -> addfield(-name='radio1', -options=array('a,b,c','d,e,f','g,h,i'), -label='testing', -type='radio', -required);
>$f -> addfield(-name='text1', -label='testing text', -type='text', -required);
>
>To trigger the bug, select a radio option, but leave text1 blank, then submit the form.  There should be an error due to a missing required value.  However, the radio does not remain selected.
>
>Next try replacing the commas with '-', and repeat.
>
>$f -> addfield(-name='radio1', -options=array('a-b-c','d-e-f','g-h-i'), -label='testing', -type='radio', -required);
>
>Here's a basic test case that runs off the Knop demo:
>
>act_foo.inc
>----------------
>$f -> loadfields;
>if(!($f -> isvalid) || $f -> error_code);
>    // remain on the same path to show form again
>    $nav -> (setlocation: ($nav -> actionpath));
>    // show error message
>    $message -> insert(($f -> error_msg) + ' ' + ($f -> error_code));
>/if;
>
>
>cfg_foo.inc
>----------------
>var: 'f'=(knop_form:
>            -formaction=($nav -> url), // real URL path
>            -method='post',
>            -actionpath=($nav -> path);
>
>$f -> addfield(-name='radio1', -options=array('a-b-c','d-e-f','g-h-i'), -label='testing', -type='radio', -required);
>$f -> addfield(-name='text1', -label='testing text', -type='text', -required);
>$f -> (addfield: -name='button_login', -type='submit', -value=$lang_ui -> login);
>
>
>cnt_foo.inc
>----------------
>[$f->renderform]
>
>I see a two instances of a suspect in Knop's form.inc:
>
>    else: #fieldvalue_array >> ','; // Other database with multiple checked
>        #fieldvalue_array = #fieldvalue_array -> (split: ',');
>
>--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: Possible Bug with Radio Not Remaining Selected?

by Johan Solve-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here is some more info about the issue with checkboxes/radios.
This behavior affects updatefields and renderform/renderhtml.


2007-01-18 JS updatefields: added support for multiple values for one fieldname, like checkboxes (multiple fields in the update pair array, -sql generates comma separated values)


In updatefields:
if: #fieldvalue -> type != 'array';
        // to support multiple values for one fieldname, like checkboxxes
        #fieldvalue = array: #fieldvalue;
/if;
if: #_sql;
        #output -> (insert:  '`' + (encode_sql(knop_stripbackticks(#fieldpair -> value -> find('dbfield') )) ) + '`'
                + '="' + (encode_sql: (#fieldvalue -> (join: ',')) ) + '"');
else;
        iterate: #fieldvalue, #onevalue;
                #output -> (insert:  (#fieldpair -> value -> (find: 'dbfield') )
                        = #onevalue );
        /iterate;
/if;


In renderform:
if: #fieldvalue_array >> '\r'; // Filemaker value list with multiple checked
        #fieldvalue_array = #fieldvalue_array -> (split: '\r');
else: #fieldvalue_array >> ','; // Other database with multiple checked
        #fieldvalue_array = #fieldvalue_array -> (split: ',');
else;
        #fieldvalue_array = array: #fieldvalue_array;
/if;


At 19.12 +0200 2009-09-21, Johan Solve wrote:

>Multi values (like multiple checkboxes) are stored in MySQL as comma separated values (this is how Lasso does it and this is how Knop handles values for checkboxes, multi selects and radios). This is what you've run into. I'll look closer at the issue later today.
>
>
>At 09.48 -0700 2009-09-21, Steve Piercy - Web Site Builder wrote:
>>Can someone confirm whether a bug exists in Knop when processing radio button options that contain a comma (,)?
>>
>>$f -> addfield(-name='radio1', -options=array('a,b,c','d,e,f','g,h,i'), -label='testing', -type='radio', -required);
>>$f -> addfield(-name='text1', -label='testing text', -type='text', -required);
>>
>>To trigger the bug, select a radio option, but leave text1 blank, then submit the form.  There should be an error due to a missing required value.  However, the radio does not remain selected.
>>
>>Next try replacing the commas with '-', and repeat.
>>
>>$f -> addfield(-name='radio1', -options=array('a-b-c','d-e-f','g-h-i'), -label='testing', -type='radio', -required);
>>
>>Here's a basic test case that runs off the Knop demo:
>>
>>act_foo.inc
>>----------------
>>$f -> loadfields;
>>if(!($f -> isvalid) || $f -> error_code);
>>    // remain on the same path to show form again
>>    $nav -> (setlocation: ($nav -> actionpath));
>>    // show error message
>>    $message -> insert(($f -> error_msg) + ' ' + ($f -> error_code));
>>/if;
>>
>>
>>cfg_foo.inc
>>----------------
>>var: 'f'=(knop_form:
>>            -formaction=($nav -> url), // real URL path
>>            -method='post',
>>            -actionpath=($nav -> path);
>>
>>$f -> addfield(-name='radio1', -options=array('a-b-c','d-e-f','g-h-i'), -label='testing', -type='radio', -required);
>>$f -> addfield(-name='text1', -label='testing text', -type='text', -required);
>>$f -> (addfield: -name='button_login', -type='submit', -value=$lang_ui -> login);
>>
>>
>>cnt_foo.inc
>>----------------
>>[$f->renderform]
>>
>>I see a two instances of a suspect in Knop's form.inc:
>>
>>    else: #fieldvalue_array >> ','; // Other database with multiple checked
>>        #fieldvalue_array = #fieldvalue_array -> (split: ',');
>>
>>--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/


--
     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: Possible Bug with Radio Not Remaining Selected?

by Steve Piercy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ouch.  Yeah, having commas in a multiple value input is not uncommon.

Instead of a split on "," perhaps a split on "','" with a
removeleading("'") and removetrailing("'") performed first?

Alternatively a more obscure character(s) could be used,
although I would not recommend a single | as that is used by a
lot of developers.  Perhaps a double-pipe or -hash (|| or ##).  
If I read this correctly, data gets stored with its values
comma-delimited in MySQL, correct?  If so, then this suggestion
would not be backward compatible, unless some kind of versioning
check is in place which would be full of suboptimalness.

What do you think about serializing the multiple values, then
joining them with a comma?  Might that work?  I suppose that
also would not be backward compatible.

Usually there is an encapsulation character and delimiter
character.  e.g., ('moose','hair') has two values that are each
encapsulated by ' and delimited by ,.  Maybe that would be more flexible?

This is a tough nut to crack.

--steve


On 9/23/09 at 12:51 AM, inbox_js@... (Johan Solve) pronounced:

>Here is some more info about the issue with checkboxes/radios.
>This behavior affects updatefields and renderform/renderhtml.
>
>
>2007-01-18    JS  updatefields: added support for multiple
>values for one fieldname, like checkboxes (multiple fields in
>the update pair array, -sql generates comma separated values)
>
>
>In updatefields:
>if: #fieldvalue -> type != 'array';
>// to support multiple values for one fieldname, like checkboxxes
>#fieldvalue = array: #fieldvalue;
>/if;
>if: #_sql;
>#output -> (insert:  '`' +
>(encode_sql(knop_stripbackticks(#fieldpair -> value ->
>find('dbfield') )) ) + '`'
>+ '="' + (encode_sql: (#fieldvalue -> (join: ',')) ) + '"');
>else;
>iterate: #fieldvalue, #onevalue;
>#output -> (insert:  (#fieldpair -> value -> (find: 'dbfield') )
>= #onevalue );
>/iterate;
>/if;
>
>
>In renderform:
>if: #fieldvalue_array >> '\r'; // Filemaker value list with multiple checked
>#fieldvalue_array = #fieldvalue_array -> (split: '\r');
>else: #fieldvalue_array >> ','; // Other database with multiple checked
>#fieldvalue_array = #fieldvalue_array -> (split: ',');
>else;
>#fieldvalue_array = array: #fieldvalue_array;
>/if;
>
>
>At 19.12 +0200 2009-09-21, Johan Solve wrote:
>>Multi values (like multiple checkboxes) are stored in MySQL as comma separated
>values (this is how Lasso does it and this is how Knop handles
>values for checkboxes, multi selects and radios). This is what
>you've run into. I'll look closer at the issue later today.
>>
>>
>>At 09.48 -0700 2009-09-21, Steve Piercy - Web Site Builder wrote:
>>>Can someone confirm whether a bug exists in Knop when processing radio button
>options that contain a comma (,)?
>>>
>>>$f -> addfield(-name='radio1', -options=array('a,b,c','d,e,f','g,h,i'),
>-label='testing', -type='radio', -required);
>>>$f -> addfield(-name='text1', -label='testing text', -type='text', -required);
>>>
>>>To trigger the bug, select a radio option, but leave text1 blank, then submit the
>form.  There should be an error due to a missing required
>value.  However, the radio does not remain selected.
>>>
>>>Next try replacing the commas with '-', and repeat.
>>>
>>>$f -> addfield(-name='radio1', -options=array('a-b-c','d-e-f','g-h-i'),
>-label='testing', -type='radio', -required);
>>>
>>>Here's a basic test case that runs off the Knop demo:
>>>
>>>act_foo.inc
>>>----------------
>>>$f -> loadfields;
>>>if(!($f -> isvalid) || $f -> error_code);
>>>    // remain on the same path to show form again
>>>    $nav -> (setlocation: ($nav -> actionpath));
>>>    // show error message
>>>    $message -> insert(($f -> error_msg) + ' ' + ($f -> error_code));
>>>/if;
>>>
>>>
>>>cfg_foo.inc
>>>----------------
>>>var: 'f'=(knop_form:
>>>            -formaction=($nav -> url), // real URL path
>>>            -method='post',
>>>            -actionpath=($nav -> path);
>>>
>>>$f -> addfield(-name='radio1', -options=array('a-b-c','d-e-f','g-h-i'),
>-label='testing', -type='radio', -required);
>>>$f -> addfield(-name='text1', -label='testing text', -type='text', -required);
>>>$f -> (addfield: -name='button_login', -type='submit', -value=$lang_ui -> login);
>>>
>>>
>>>cnt_foo.inc
>>>----------------
>>>[$f->renderform]
>>>
>>>I see a two instances of a suspect in Knop's form.inc:
>>>
>>>    else: #fieldvalue_array >> ','; // Other database with multiple checked
>>>        #fieldvalue_array = #fieldvalue_array -> (split: ',');
>>>
>>>--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/
>
>
>--
>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/