Would it be possible to send an e-mail to a selected user.
Something like : Ask the the teacher
A student chooses his teacher
Fills out a text area
And submit an e-mail to the e-mailaddress of this choosen teacher
The number of teachers and students are changing, so the name of the teacher and his corresponding e-mail should be extracted from the db I quess
I would appreciate if you could help me out
Yes you can do that.
Use a DB Load/Read action to get the list of teachers and use the Dynamic Data tab in a Drop-down element to add them to a drop-down.
It isn't good practice to add the teacher emails in the form so you can look them up using a second DB Load/Read in the On Submit event and use the Email in the Dynamic To box of the Email action.
Bob
I put the DB Record Loader in the OnLoad event
I selected table jos2_users
And for the DB Field I put in: name
For the Preview area, in teh drop-down, I enabled Dynamic Data and at Value-key I put in "name"
Looking in the FE, it does give me the names
Where did I miss something?
For the drop-down options you need a 'value' and a 'text'. Id use the ID and the name from the #__users table so the names show in the drop-down and the user ID is returned when the form is submitted.
Bob
Dynamic Data from a database table
You can use the ChronoForms DB Multi Record Loader action (or the DB Read action in CFv5) to create a data-set to use as your option list. You need to drag a copy of the action into the On Load event of your form and move it up before the Show HTML action. On the action General Tab you need to set at least the Table and Fields boxes (you may well need to complete others to select the records that you want to use).
For example, we might select the jos_content table and then add id,title in the Fields box. Note that the Model ID will default to josContent unless you set another value.
Save the action and go back on the Dynamic Data tab on the element. Enable the Dynamic Data; enter the Model ID josContent in the 'Model ID' box, then id in the 'value' box and title in the 'text' box.
Save the element and test the form, you should see a list of options that display the article titles as labels and return the matching article id when the form is submitted.
If you want to create a simple list where the value and label are the same you can just put title in both of the 'value' and 'text' boxes.
In the "db loader" config, the "db field" should be empty, because you want to load all records!
You must enable the "load under model id", and enter a "model id", which you are going to use later in the "data path" field!
The fields names are case sensitive, so you need to use "id" but not "ID" if that's the field name in your table!
Regards,
Max
What do you have in the rest of the debug ?
Here it is:
Array
(
[option] => com_chronoforms
[chronoform] => DOCENTEN
[Itemid] =>
)
The empty Validation Errors array just means that no errors were found.
Please drag a Debugger action into the On Load event, then load the form and post the debug results here.
Bob
See my reply abve, but here are the results again:
Data Array:
Array
(
[option] => com_chronoforms
[chronoform] => DOCENTEN
[Itemid] =>
)
Validation Errors:
Array
(
)
( There is nothing on the [itemid]=> part....)
There should be some out put there from the DB Load action and I don't see anything. Is the Debugger after the DB Load action?
Bob
Regards,
Max
It should work though...
And it works now!
So, I assume the DB Recordloader in V4 is not working correctly.
Pls yr views on this...
I tried your earlier suggestion, but I cannot get the mail function correctly
On a different site everthing works fine now in V5, however, how can I get an email send out to the emailaddress of the selected user?
This did not bring me further "It isn't good practice to add the teacher emails in the form so you can look them up using a second DB Load/Read in the On Submit event and use the Email in the Dynamic To box of the Email action."
Pls advise
The DB Record Loader in CFv4 works correctly. There are no problems with it if it is configured correctly.
To get the email of the selected user you need to use a second DB Read action in the On Submit event and use the value from the drop-down to look up the matching address. In this case you just need to get a single result.
Bob
V4 DB read action does not work! I configured excactly like the V5 version!
No idea what you are saying with this:
To get the email of the selected user you need to use a second DB Read action in the On Submit event and use the value from the drop-down to look up the matching address. In this case you just need to get a single result.
Maybe ther is an example somewhere??
The v4 action works, but you need to use the "db multi record loader" in order to load a list of records, in v4 the "db record loader" requires a request param or WHERE code to work!
Then, for security reasons, you will use the following fields in the text and value boxes in your dropdown: id, name
Then, as Bob explained, you need a "db record loader" in the "on submit", with the name of the dropdown field in the "request param" and "id" in the "db field", to load the selected user's info then use it as the "dynamic to" address, you should the "load undre model id" to NO in this action, and write "email" in the "dynamic to" field.
Regards,
Max
In J3.x I managed to get it working in the V5 version.
Now the V4 version:
I used the DB Record Loader instead teh Multirecord Loader 😟
So, the first part (to show the users) works now.
But the second part, to send out an email is still (my) problem.
Pls find some pictures of the Preview (drop down element) en the DB Record Loader in the OnSubmit area.
(in the email part in the tab Dynamic date is put "email" in the dynamic to field.
Where did I miss your guidance to get V4 working as well?
You can add a debugger action after the "db record loader" to check its working as expected.
What's the field name of yoru dropdown ? is it name ? because you use "name" in the request param, that should match the dropdown field name.
Then, you don't have a table selected!!! you must select the users table.
Regards,
Max