I have Willr's UserForms installed on my site. I would like to create a form to allow members to email themselves. I thought that the 'Member Field' would allow users to select the member they wish to contact. Unfortunately, that field doesn't provide an email address for the form to send the message. Would it be possible to create such a form?
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
You could create your own field type for that pretty easily. If you have a look at EditableMemberListField it does pretty much what you want but rather than returning the name from getValueFromData() you would want to return the email address.
Sending the email is a little tricker, you could adapt the Userform Email Recipient popup to allow you to select an EditableMemberList field as the 'Send To' option.
How would I create a field for this? In the list of fields, there is a Member List Field, but no EditableMemberListField.
Once the field is created, I think I could add it to the "send to" email field on my own.
How would I create a field for this? In the list of fields, there is a Member List Field, but no EditableMemberListField.
The editable member list field is the class name of the field. You can see the class in userforms/code/editor/. The module will automatically pick up any subclasses of 'EditableFormField' and display it in the editor.
In your cause you could extend the EditableMemberListField class with your own class and override the getValueFromData() method to return the email.
Okay, I see the file you are talking about, but the rest of the process is a complete mystery to me. I see a bunch of code in the file, but I don't have a clue on how to change that code for my needs.
Forgive my ignorance please. Perhaps someone can provide the code I need so I can just cut-and-paste? Or perhaps just creating a new file for me to use? I don't want to be a pain, but I don't want to screw up the utility by modifying the file incorrectly.
ETA: If possible, I would also like the 'From' field to automatically select the current user who is sending the message.
Ah yes, sorry my instructions were designed for more of a developer. If no one responds you may want to post this as a small job to oDesk or similar to commission a developer to get it working to your needs.