Skip to content

Commit

Permalink
Merge pull request #14 from slub/fix-select-fields
Browse files Browse the repository at this point in the history
Fix bug if using select fields and multiple forms on one page
  • Loading branch information
Alexander Bigga authored Dec 28, 2021
2 parents b6a1d41 + 666bd5c commit b32fb13
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Forms/Textfield.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<f:form.textfield id="slub-forms-field-{form.uid}-{fieldset.uid}-{field.uid}"
class="{f:if(condition: fieldset.required, then: 'requiregroup-{form.uid}-{fieldset.uid}')} {f:if(condition: field.isSenderName, then: 'sender-name')} {f:if(condition: field.isSenderEmail, then: 'sender-email')} {field.shortname}"
name="field[{fieldset.uid}][{field.uid}]"
type="{field.validation}"
type="{field.validation}"
readonly="{sf:condition.isReadonlyField(field: '{field}')}"
title="<f:translate key='validationerror_val_{field.validation}' />"
value="<sf:form.fieldHasValue field='{field}' />"
Expand Down
22 changes: 14 additions & 8 deletions Resources/Public/Js/FormValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,21 @@ jQuery(document).ready(function() {
* @return void
*/
function hideAllForms() {
$('.slub-forms-form').addClass('hide'); // show all fields and fieldsets
$('.slub-forms-fieldset').find('input').prop('disabled', true);
$('.slub-forms-fieldset').find('textarea').prop('disabled', true);
$('.slub-forms-form').addClass('hide'); // hide all forms

disableAllHiddenForms();
}

/**
* Hide all forms
* Disable all hidden forms
*
* @return void
*/
function disableAllHiddenForms() {

$('.slub-forms-form.hide .slub-forms-fieldset').find('input').prop('disabled', true);
$('.slub-forms-form.hide .slub-forms-fieldset').find('textarea').prop('disabled', true);
$('.slub-forms-form.hide .slub-forms-fieldset').find('select').prop('disabled', true);

}

Expand All @@ -105,11 +106,16 @@ function showForm(uid) {
return;
}

// initially hide all forms
hideAllForms();

$('#slub-forms-form-' + uid).removeClass('hide'); // hide current field
// show only form with given uid
$('#slub-forms-form-' + uid).removeClass('hide');

// enable all fields of this form
$('#slub-forms-form-' + uid).find('input').prop('disabled', false);
$('#slub-forms-form-' + uid).find('textarea').prop('disabled', false);
$('#slub-forms-form-' + uid).find('select').prop('disabled', false);

setCookie('sf_form', uid);

Expand All @@ -127,15 +133,15 @@ function showForm(uid) {
}

/**
* Show a form
* Hides a form
*
* @param integer uid: uid of the element
* @return void
*/
function hideForm(uid) {
$('#slub-forms-form-' + uid).addClass('hide'); // hide current field
$('#slub-forms-form-' + uid).find('input').prop('disabled', true);
$('#slub-forms-form-' + uid).find('textarea').prop('disabled', true);

disableAllHiddenForms();
setCookie('sf_form', '');
}

Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
'modify_tables' => '',
'clearCacheOnLoad' => 0,
'lockType' => '',
'version' => '1.0.4',
'version' => '1.0.5',
'constraints' => array(
'depends' => array(
'typo3' => '9.5.28-9.5.99',
Expand Down

0 comments on commit b32fb13

Please sign in to comment.