AEM Forms Custom Widget - Multiple Values

Avatar

Avatar

James_R_Green

Avatar

James_R_Green

James_R_Green

15-12-2017

I am creating a custom widget for a client. It is a slider with a 'n/a' checkbox.

The slider works fine, and I can see that the '_value' attribute on the guidestate is set to the value from the slider.

However, I would like to also send the status of the n/a checkbox on submit also. I could save it to the _value field as well and add code to handle 'n/a' differently...but that seems messy.

Is it possible to set a different attribute other than _value on a custom widget? Perhaps a new field such as isNotApplicable

Thanks,

James

Accepted Solutions (0)

Answers (7)

Answers (7)

Avatar

Avatar

James_R_Green

Avatar

James_R_Green

James_R_Green

18-02-2018

jagjeetthukral

I couldn't get this to work. My client's requirements changed so I didn't need to do this in the end.

It would be useful for other people however if you had a small example of how to do this. Maybe something simple, like 1 widget that has two textboxes?

Thanks,

James

Avatar

Avatar

jagjeetthukral

Avatar

jagjeetthukral

jagjeetthukral

12-02-2018

James R Green​, were you able to get this to work? Please let me know in case you need any further help.

Cheers,

Jagjeet Singh

AEM Forms Blog

Avatar

Avatar

James_R_Green

Avatar

James_R_Green

James_R_Green

06-02-2018

Thanks I will check this out!

Avatar

Avatar

jagjeetthukral

Avatar

jagjeetthukral

jagjeetthukral

05-02-2018

Hi James,

What I would suggest is that you create a guideCompositeWidget, much like the fileupload or TnC box. The only difference is you should be using custom widgets instead of the OOTB widgets.

Hope this helps!!!

Cheers,

Jagjeet

AEM Forms Blog

Avatar

Avatar

James_R_Green

Avatar

James_R_Green

James_R_Green

05-02-2018

smacdonald2008​ - Are you able to query this with the dev team please?

The use case I have is to add more than one value entered by a user from a custom widget to the guide state.

The problem I have is I can only set "_value" via the getCommitValue of my custom widget, in total I need to store 3 values:

1) The value of the range slider (1-100)

2) A comment from a textbox within the same widget

3) The value of a radio button to say if the question is N/A

The custom widget easily allow me to store one of these values, but I cannot see an easy way to store multiple/custom values.

Workarounds that I have tried so far include:

1) Representing 'N/A' as -1 value on the slider - this worked but doesn't cater for the comments.

2) I can store a stringified JSON object in _value containing all 3 values, and parse it in getOptionsMap. This works, but is pretty hacky.

Ideally I would have an example that shows how I can add custom properties to the guidestate e.g.

guidecustomwidget:{

     "jcr:title":"Question 1"

     "name": "Q1

.....

     "_value": "Value from the slider".

     "applicable":true/false,

     "comment":"Text entered in the comment textbox"

}

Thanks,

James

Avatar

Avatar

James_R_Green

Avatar

James_R_Green

James_R_Green

09-01-2018

Still required. Can anyone help?

Avatar

Avatar

James_R_Green

Avatar

James_R_Green

James_R_Green

21-12-2017

Still require help with this one. Any suggestions? Even confirming it is not possible would be useful