Prefill TYPO3 Powermail form from session? - typo3

Users can register for various events with powermail forms on a TYPO3 6.2 site.
There is no shopping cart.
For a better ux, is it possible prefill typical fields in the register form based on the user's previous input?
For example, allow the user to control this with a checkbox "save my address for use in other forms", storing his address in a session, which can be reused to prefill the next form?

The solution is on
https://docs.typo3.org/typo3cms/extensions/powermail/ForAdministrators/GoodToKnow/SaveSession/Index.html and https://forge.typo3.org/issues/69507#change-274061
Save values to a session:
plugin.tx_powermail.settings.setup {
# Save submitted values in a session to prefill forms for further visits. Define each markername for all forms.
saveSession {
# Method "temporary" means as long as the browser is open. "permanently" could be used together with a frontend-user session. If method is empty, saveSession is deactivated.
_method =
firstname = TEXT
firstname.field = firstname
lastname = TEXT
lastname.field = lastname
}
}
[globalVar = GP:tx_powermail_pi1|field|checkboxmarkername|0 > 0]
plugin.tx_powermail.settings.setup.saveSession._method = temporary
[end]

you can do one thing for this, i think you can do this by simply using javascript.
Store one address value with one variable and after on click/check event of radio/checkbox you can make same content copy there.
var addre1 = $('.residentAddress').val();

Related

How to convert an email address into a link via typoscript

In Typo3 I have a content element with a plain text field (no RTE / CKEditor field). In case a user enters an e-mail address, it should be automatically converted into an e-mail link. How can I achieve this with Typoscript or even directly in Fluid-Script?
This is my approach: per <f:cObject ... /> pass the text to a typoscript, which searches for an #-character, selects the whole word and then adds the corresponding A-tags:
<f:cObject typoscriptObjectPath="lib.emaillink" data={adrtxt: tx_mask_cnt_consultation_adr_item_txt} />
lib.emaillink = COA
lib.emaillink {
5 = LOAD_REGISTER
5 {
dAdrTxt.data = field:adrtxt
}
10 = TEXT
10 {
data = register:dAdrTxt
# Search for '#', select whole word, add A-tags ... ?
}
}
Thank you in advance for any help!
That was a feature of TYPO3, but it changed in details from version to version.
Sometimes you need a prefix mailto: sometimes you must avoid that prefix.
Especially if you want to hide the emailaddress from email-harvesters, an email was encrypted linked with javascript and the visible (original) email address was modified to fool regexp searching.
have a look at the manual
config {
spamProtectEmailAddresses = -5
spamProtectEmailAddresses_atSubst = <span class="at">(at)</span>
}
(with the option to replace all span-tags with class at by a simple # on runtime, so the email looks normal to a visitor.
As I always use this encryption, I can't say whether it only works with this feature active. Give it a try.

Eloqua Forms: how to show/hide fields depending on others fields

Eloqua Forms
I want to know if there is some way to show or hide fields (or sections) depending on what values of others fields.
Of course, I am asking on some OOTB behavior; if not, will do it with JS.
Thanks in advance.
Unfortunately, Eloqua does not have a conditional rules for form field visibility (at least not yet. Dependent Field Visibility/Logic).
Until that functionality is brought into Eloqua Forms, you would have to write some Javascript to accomplish this.
You would need a listener (onchange in example).
Eloqua uses dynamic ids for form field elements based upon order. Setting the "HTML Name" value for the fields in the form editor allows for a more stable reference.
var fieldToListenTo = document.getElementsByName('eloquaHTMLName1')[0];
var fieldToChange = document.getElementsByName('eloquaHTMLName2')[0];
fieldToListenTo.onchange = function(){
if(fieldToListenTo == 1) {
fieldToChange.value = "New Value 1";
}
else {
fieldToChange.value = "New Value 2";
}
}

TYPO3 EXT:powermail prefill or preselect a field via url

I have my own TYPO3 plugin that displays records. Now I want to add a link to a second page to each record.
The second page should be a powermail form. Now I want that the link to the second Mail contains a parameter that should prefill a input field in the powermail form.
Is that possible? And if so how?
Yes it is possible. See documentation of powermail: https://docs.typo3.org/typo3cms/extensions/powermail/ForAdministrators/BestPractice/PrefillField/Index.html
The standard way
Prefilling (input, textarea, hidden) or preselecting (select, check, radio) of fields will be done by the PrefillFieldViewHelper. It listen to the following methods and parameters (in this ordering):
GET/POST param like &tx_powermail_pi1[field][marker]=value
GET/POST param like &tx_powermail_pi1[marker]=value
GET/POST param like &tx_powermail_pi1[field][123]=value
GET/POST param like &tx_powermail_pi1[uid123]=value
If field should be filled with values from FE_User (see field configuration)
If field should be prefilled from static Setting (see field configuration)
Fill with TypoScript cObject like
plugin.tx_powermail.settings.setup.prefill {
# Fill field with marker {email}
email = TEXT
email.value = mail#domain.org
}
Fill with simple TypoScript like
plugin.tx_powermail.settings.setup.prefill {
# Fill field with marker {email}
email = mail#domain.org
}
Fill with your own PHP with a Signal. Look at In2codePowermailViewHelpersMiscPrefillFieldViewHelper::render()

How can I get item response id"s?

I have made a formsystem (Drivea) that can be used by bridgeclubs for signing up for a bridgedrive. The first question of the signing up form (form 1) is to choose between (1) signup, (2) change their former signedup data or (3) to withdraw from the bridgedrive after signing up earlier.
When people want to change their former signedup data they have to give only a numbercode (was given in the confirmationmail after signing up) and their emailadress. Directly they get an email in which the prefilled Url is given. This prefilled Url gives another form than the first form (with the 3 choises as mentioned above) with almost the same questions. The data are picked up from the responsesheet of the first form and filed in the prefilled Url from the second form. After changing data and submit the second form the new data are copied again to the responsesheet of form 1.
In the prefilled url are the itemresponse id's with corresponding data. These numbers are given by get the url of form 2. Those numbers are used in the script of form 1 to construct the prefilled Url. This is working very good because those numbers never change as long the questions of both forms are not changing.
So far so good.
Now I am developping that in the form a bridgeclub can add an extra question (item). They are able to remove that extra item and if necessarry to bring back an extra (other) question. This is possible by a few functions I made.
However when an extra item is set in the form (and automaticly also in form 2) every time the itemresonse Id is changing of that extra question. So i am looking for a solution to find the response id of that question in form 2 before this question in the form was filled in.
In a form you kan get the Id (number) of an item by item.getId(). When the form is made those Id's are allocated directly.
To get the itemresponse id's you have to go to the form (edit) en get the prefilled Url. After filling in and submit the form the url with the itemresponse id's is shown. As mentioned above for form 2.
It seems to me logical that, as with the item id's, those itemresponse id's are already known before filling in all answers of the form to get the prefilled Url.
My question is how can I get programmaticly those itemresponse id's?
Problem solved. Response Id numbers are not necessary to get the prefilled url.
OnformSubmit (e) {
......
var formResponse = form2.createResponse();
// Prefill first name
var formItem = itemsform2[0].asTextItem();
var response = formItem.createResponse(sourcedata[i-1][2]);
formResponse.withItemResponse(response);
// Prefill insertion
var formItem = itemsform2[1].asTextItem();
var response = formItem.createResponse(sourcedata[i-1][3]);
formResponse.withItemResponse(response);
// Prefill family name
var formItem = itemsform2[2].asTextItem();
var response = formItem.createResponse(sourcedata[i-1][4]);
var url = formResponse.toPrefilledUrl();
......
}
i is the row in the response sheet of form 1, sourcedata is the answer in that row and formitem is the corresponding item in form 2.
It works very good.

Unique field in user registration form in Drupal 7

I am working in drupal 7. I need a field in the user registration form which needs to be unique. It is an integer field which stores the ID of the user. I have been searching around for a few hours now without any development. Can someone guide me through this?
Thank You.
You can add a custom "staff id" field to the user entity type from admin/config/people/account/fields (configuration->people->account settings). You can add a new integer field, and mark it to display in the registration form, and/or required.
To check that the field value is unqiue you will need to use a custom module. In your custom module use the form_id_form_alter hook to add a custom validation to the registration form. Then during validation you can check that the value does not already exist in the database and return a form error.
Example of the custom module:
<?php
function mymodule_form_user_register_form_alter(&$form, &$form_state, $form_id){
$form['#validate'][] = 'mymodule_user_registration_validate';
}
function mymodule_user_registration_validate(&$form,&$form_state){
$staff_id = $form_state['values']['staff_id_field'];
$check_unique_query = 'SELECT field_staff_id_value FROM {field_data_staff_id} WHERE field_staff_id_value = :staff_id LIMIT 1';
//if a result is returned, that means the $staff_id exists
if (db_query($check_unique_query,array(':staff_id'=>$staff_id))->fetchField()){
form_set_error('staff_id_field','This Staff ID is already in use');
}
}
Have you tried the Unique field module? Pretty sure it does what you need here.
Field validation does the trick https://drupal.org/project/field_validation. You can set any rules per field even on the registration form