knop-project / knop

Web application framework for Lasso 8 and 9
18 stars 46 forks source link

Don't coerce an array to a string for form -> getbutton #115

Open stevepiercy opened 9 years ago

stevepiercy commented 9 years ago

This is madness.

https://github.com/knop-project/knop/blob/master/knop9/knoplibs/knop_form.lasso#L1042-L1054

        local(clientparams = .'clientparams' -> asstring)
        // look for submit buttons, the least destructive first
        with i in array('cancel', 'save', 'add', 'search', 'delete') do => {
            if(#clientparams >> 'button_' + #i
                || #clientparams >> 'button_' + #i + '.x'
                || #clientparams >> 'button_' + #i + '.y') => {
                .'formbutton' = #i
                return #i
            }
        }

coercing the object to a string means that buttons named 'button_saveaddanother' and 'button_savecheckout' both return 'save' for form -> getbutton. The workaround is to insert an arbitrary string that does not much any of the five values in the array.