dcwaterm / pwm

Automatically exported from code.google.com/p/pwm
0 stars 0 forks source link

Allow checkbox as part of FormConfiguration #504

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I would like to be able to include a checkbox (and/or drop down list of values) 
in the registration/update details form

As part of this I need to be able to specify which values are represented by 
checked/not checked (default true/false but also allows for 1/0 etc)

In order to allow specified values I made the following change in 
PwmSetting.properties

In PwmSetting.properties modify the regex

REGEX_newUser.form=^[a-zA-Z][a-zA-Z0-9-]*:.+:(text|tel|number|email|password|hid
den|checkbox):[0-9]+:[0-9]+:(true|false):(true|false)(:[a-zA-Z0-9-,]*)?$

(I allowed for more than 2 comma seperated values to permit extension for 
select)

In NewUserServlet I made the following change at line 332

        // set up the user creation attributes
        final Map<String,String> createAttributes = new HashMap<String,String>();
        for (final FormConfiguration formConfiguration : newUserForm) {
            final String attributeName = formConfiguration.getAttributeName();
            final String value = AttributeValueModifier.getAttributeValue(formConfiguration,formValues);
            createAttributes.put(attributeName, value);
        }

Also attached modified FormConfiguration and new class

Original issue reported on code.google.com by ian.well...@gmail.com on 23 Oct 2013 at 11:15

Attachments:

GoogleCodeExporter commented 9 years ago
Slightly more complicated to set up for update profile form so the following:

Same change to REGEX_updateAttributes.form in PwmSetting.properties

In UpdateProfileServlet at line 168
        for (final FormConfiguration formConfiguration : formFields) {
            final String attrName = formConfiguration.getAttributeName();
            if (!formProps.containsKey(attrName)) {
                final String userCurrentValue = AttributeValueModifier.setAttributeValue(formConfiguration, currentUserAttributes);

                if (userCurrentValue != null) {
                    formProps.setProperty(attrName, userCurrentValue);
                }
            }
        }
Change in Helper.java writeFormValuesToLdap line 660
for (final FormConfiguration formConfiguration : formValues.keySet()) {
            final String value = AttributeValueModifier.getAttributeValue(formConfiguration, formValues.get(formConfiguration));
            tempMap.put(formConfiguration.getAttributeName(), value);
        }

(Suggest NewUserServlet uses Helper.writeFormValuesToLdap)

Update NewUserServlet change above to:
            final String attributeName = formConfiguration.getAttributeName();
            final String value = AttributeValueModifier.getAttributeValue(formConfiguration, formValues.get(attributeName));
            createAttributes.put(attributeName, value);

Original comment by ian.well...@gmail.com on 25 Oct 2013 at 8:10

Attachments: