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";
}
}
Related
I have to make a huge form in a drupal website, it's for a travel agency and it's a satisfaction questionnaire.
At the beggining of the form the user choose the type of travel he do, and after this all the fields depend of the first answer, for each type of travel there is different fields to complete.
So my question is what's the best way to do this form (there is 12 type of travel, so 12 different set of fields (~50 field / type)).
I think webform could be usable with the webform conditionnal fields, but the problem I think i'll have with webform is when I want to export the data, in the CSV I'll have ALL the fields of ALL the travel type, and this will be illisible.
I search for it but doesn't find if this is possible to hide fields of the csv programmatically.
A second way I found in internet is the CCK, but I have no experience with this.
Do you have any suggestion ?
you can use hook provided by webform module :
/**
* Alter a Webform submission's data when exported.
*/
function hook_webform_csv_data_alter(&$data, $component, $submission) {
// If a value of a field was left blank, use the value from another
// field.
if ($component['cid'] == 1 && empty($data)) {
$data = $submission->data[2]['value'][0];
}
}
Found in webform.api.php into webform module folder
Also you can modify submit function by own altering form process :
function hook_form_alter(&$form, &$form_state , $form_id){
if ($form_id == 'myformid'){
$form['#submit']= array('mycustomsubmit'); // or loop on existing to suppress only unwanted submit callbacks
}
}
function mycustomsubmit($form , &$form_state){
// do your stuffs csv exports
}
I have a custom page type, and the editor will have the option to enter the following
Image (from media library)
Video (from media library)
YouTube video ID
The field names are as follows
SlideImage
SlideVideo
YouTubeVideoID
So, if an editor ads a SlideImage, SlideVideo and YouTubeVideoID should not be usable. Same for SlideVideo and YouTubeVideoID.
Within the Visibility Condition fields, i'm going to assume a macro is needed for this. My logic is:
This field visible if Field A or B have data.
A possible approach can be to add an additional field, which determines the field that should be used.
Create a text field (let's say, SlideType) and use a radio button form control with your options:
image;Image
video;Video
youtube;YouTube
Tick the "Has depending fields" checkbox for this field, and tick the "Depends on another field" checkbox for the SlideImage, SlideVideo and YouTubeVideoID fields.
Your visibility conditions would then be simplified, instead of checking the values of multiple fields.
For example, the visibility condition for the SlideVideo field would be:
SlideType == "video"
This has a few benefits:
Easy to add new fields and configure the visibility conditions
Easy to check what needs to be rendered in the front-end - in your repeaters and other webparts, you can simply have conditional statements on the SlideType field to determine which field to use
Intuitive for the end user - the interface makes it clear which field is being used
Add this to Visibility condition in Page type field edit:
Fields.SlideImage.Value == String.Empty
Do not forget to set proper Has depending fields and Depends on another field properties depending on your needs. You can learn more about these properties here.
Let's say the column name on which this value of your depending field is "FirstName", so you can write in the dependent field -> Visibility Condition as
FirstName.value != ""
or
FirstName.value
You can twist the conditions for as many conditions as possible and can club more than one condition too.
I am also sharing links with you having a lot of examples from Kentico support
Dependency fields in Kentico
Using dependency fields in forms
Cheers,
Chetan
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();
In Drupal 7, is there a way to change the standard edit form for a content type based on a certain content?
For example:
I have a content type with a checkbox...once it it checked and the form is saved, I do not want this checkbox to be visible anymore...therefore based on the checkboxes value in the Database I want to hide form fields when showing the form.
I am building a small specific project site, where a company wants to add projects, and their customers are supposed to follow certain steps (upload some content, provide information etc.), and also should be able to check off certain requirements, and once these are checked off, they should not be visible/editable to them.
Also the displayed form fields should depend on an user's role, and then FURTHER be limited depending on the content's database entries.
Is there a module, which could achieve this behaviour? "rules" and "field/permissions" come close to what I need, but are not sufficient. Or did I just miss the option to change a form field's accessibility based on conditions?
What I need is some place to define a logic like "IF (VALUEOF(CHECKBOX_1) == TRUE) THEN DO_NOT_SHOW(CHECKBOX_1)"
hook_form_alter is the way to do this, as explained by Mihaela, but what options do you have inside that function?
If you want just to disable field (it will be visible, but user can't change it) you can do it like this:
$form['field_myfield']['#disabled'] = TRUE;
And if you want it to be hidden, but to keep value it has before editing the way to do that is:
$form['field_myfield']['#access'] = FALSE;
I.e. hiding it (somewhere I saw someone suggesting that):
hide($form['field_myfield']);
really hides the field, but after that, when form is saved this field has empty value, validation fails, etc, so that's not a good way to do this. Hiding makes sense only if you want to print separately that field later, at some other place.
function your_module_form_alter(&$form, &$form_state, $form_id){
switch($form_id) {
case 'nameOfTheNode_node_form':
//your code here. check the value from from_state.
break;
}
}
In this case, I use module Conditional Fields https://www.drupal.org/project/conditional_fields
For example: If my Dependees field has a value, Dependent field can be visible/invisible, enabled/disabled, required/optional, checked/unchecked
I'm creating a PDF form with a submission button. I would like the form to email based on the value of another form in the field. I'm assuming I need to do an "IF...ELSE" statement, but keep getting a syntax error that I cannot figure out. I am completely java illiterate.
This can be done using multiple solutions, but you do need to program Javascript inside of the PDF. You can use if-else on-click of the email-button. Here you can check values entered inside of the PDF form:
if (this.getValue("somefield") == "left") { emailvalue = "toA#domain.com" } else { emailvalue = "toB#domain.com" }
But you could also set the value onBlur or onFocus of a certain field. Like with radio-buttons the onBlur is useful because you know the user clicked or focused on this field and so set the variable emailvalue to a certain value.