diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b4272c9a..b5045765d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/). +## [8.14.6] + +### Fixed + +- Input, date, phone, rating, and textarea components: separated `fieldHideLabel` into a conditional assignment so it is only passed when explicitly set to true, allowing the field component's default hide-label behavior to work correctly. +- Removed unused `missingType.generics` PHPStan ignore rule. + ## [8.14.5] ### Fixed @@ -1709,6 +1716,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a - Initial production release. +[8.14.6]: https://github.com/infinum/eightshift-forms/compare/8.14.5...8.14.6 [8.14.5]: https://github.com/infinum/eightshift-forms/compare/8.14.4...8.14.5 [8.14.4]: https://github.com/infinum/eightshift-forms/compare/8.14.3...8.14.4 [8.14.3]: https://github.com/infinum/eightshift-forms/compare/8.14.2...8.14.3 diff --git a/eightshift-forms.php b/eightshift-forms.php index 95386dc3e..9da1f9218 100644 --- a/eightshift-forms.php +++ b/eightshift-forms.php @@ -6,7 +6,7 @@ * Description: Eightshift Forms is a complete form builder plugin that utilizes modern Block editor features with multiple third-party integrations, bringing your project to a new level. * Author: WordPress team @Infinum * Author URI: https://eightshift.com/ - * Version: 8.14.5 + * Version: 8.14.6 * Text Domain: eightshift-forms * * @package EightshiftForms diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 32897809c..1f588864e 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -15,5 +15,4 @@ parameters: ignoreErrors: # Block templates - '/^Variable (\$attributes|\$renderContent|\$manifest|\$globalManifest) might not be defined\.$/' - - identifier: missingType.generics diff --git a/src/Blocks/components/date/date.php b/src/Blocks/components/date/date.php index b66584322..fe8873332 100644 --- a/src/Blocks/components/date/date.php +++ b/src/Blocks/components/date/date.php @@ -87,26 +87,32 @@ class="' . esc_attr($dateClass) . '" ' . $additionalContent . ' '; +$fieldOutput = [ + 'fieldContent' => $date, + 'fieldId' => $dateId, + 'fieldTypeInternal' => FormsHelper::getStateFieldType($dateType === 'date' ? 'date' : 'dateTime'), + 'fieldName' => $dateName, + 'fieldTwSelectorsData' => $dateTwSelectorsData, + 'fieldIsRequired' => $dateIsRequired, + 'fieldDisabled' => !empty($dateIsDisabled), + 'fieldTypeCustom' => $dateTypeCustom ?: $dateType, // phpcs:ignore WordPress.PHP.DisallowShortTernary.Found + 'fieldTracking' => $dateTracking, + 'fieldConditionalTags' => Helpers::render( + 'conditional-tags', + Helpers::props('conditionalTags', $attributes) + ), + 'fieldAttrs' => $dateFieldAttrs, +]; + +// Hide label if needed but separated like this so we can utilize normal fieldHideLabel attribute from field component. +if ($dateHideLabel) { + $fieldOutput['fieldHideLabel'] = true; +} + echo Helpers::render( 'field', array_merge( - Helpers::props('field', $attributes, [ - 'fieldContent' => $date, - 'fieldId' => $dateId, - 'fieldTypeInternal' => FormsHelper::getStateFieldType($dateType === 'date' ? 'date' : 'dateTime'), - 'fieldName' => $dateName, - 'fieldTwSelectorsData' => $dateTwSelectorsData, - 'fieldIsRequired' => $dateIsRequired, - 'fieldDisabled' => !empty($dateIsDisabled), - 'fieldTypeCustom' => $dateTypeCustom ?: $dateType, // phpcs:ignore WordPress.PHP.DisallowShortTernary.Found - 'fieldTracking' => $dateTracking, - 'fieldHideLabel' => $dateHideLabel, - 'fieldConditionalTags' => Helpers::render( - 'conditional-tags', - Helpers::props('conditionalTags', $attributes) - ), - 'fieldAttrs' => $dateFieldAttrs, - ]), + Helpers::props('field', $attributes, $fieldOutput), [ 'additionalFieldClass' => $attributes['additionalFieldClass'] ?? '', 'selectorClass' => $manifest['componentName'] ?? '' diff --git a/src/Blocks/components/input/input.php b/src/Blocks/components/input/input.php index fe9ec9918..8d2940a6d 100644 --- a/src/Blocks/components/input/input.php +++ b/src/Blocks/components/input/input.php @@ -163,27 +163,33 @@ class="' . esc_attr(FormsHelper::getTwBase($twClasses, 'range', "{$componentClas $input .= $additionalContent; } +$fieldOutput = [ + 'fieldContent' => $input, + 'fieldId' => $inputId, + 'fieldName' => $inputName, + 'fieldTwSelectorsData' => $inputTwSelectorsData, + 'fieldTypeInternal' => FormsHelper::getStateFieldType($inputType === 'range' ? 'range' : 'input'), + 'fieldIsRequired' => $inputIsRequired, + 'fieldDisabled' => !empty($inputIsDisabled), + 'fieldUseError' => $inputType !== 'hidden', + 'fieldTypeCustom' => $inputTypeCustom ?: $inputType, // phpcs:ignore WordPress.PHP.DisallowShortTernary.Found + 'fieldTracking' => $inputTracking, + 'fieldConditionalTags' => Helpers::render( + 'conditional-tags', + Helpers::props('conditionalTags', $attributes) + ), + 'fieldAttrs' => $inputFieldAttrs, +]; + +// Hide label if needed but separated like this so we can utilize normal fieldHideLabel attribute from field component. +if ($inputHideLabel || $inputType === 'hidden') { + $fieldOutput['fieldHideLabel'] = true; +} + echo Helpers::render( 'field', array_merge( - Helpers::props('field', $attributes, [ - 'fieldContent' => $input, - 'fieldId' => $inputId, - 'fieldName' => $inputName, - 'fieldTwSelectorsData' => $inputTwSelectorsData, - 'fieldTypeInternal' => FormsHelper::getStateFieldType($inputType === 'range' ? 'range' : 'input'), - 'fieldIsRequired' => $inputIsRequired, - 'fieldDisabled' => !empty($inputIsDisabled), - 'fieldUseError' => $inputType !== 'hidden', - 'fieldTypeCustom' => $inputTypeCustom ?: $inputType, // phpcs:ignore WordPress.PHP.DisallowShortTernary.Found - 'fieldTracking' => $inputTracking, - 'fieldHideLabel' => $inputHideLabel || $inputType === 'hidden', - 'fieldConditionalTags' => Helpers::render( - 'conditional-tags', - Helpers::props('conditionalTags', $attributes) - ), - 'fieldAttrs' => $inputFieldAttrs, - ]), + Helpers::props('field', $attributes, $fieldOutput), [ 'additionalFieldClass' => $attributes['additionalFieldClass'] ?? '', 'selectorClass' => $inputType === 'range' ? 'range' : $manifest['componentName'] ?? '', diff --git a/src/Blocks/components/phone/phone.php b/src/Blocks/components/phone/phone.php index 96e1932b5..7b54c51a5 100644 --- a/src/Blocks/components/phone/phone.php +++ b/src/Blocks/components/phone/phone.php @@ -157,26 +157,32 @@ class="' . esc_attr($phoneClass) . '" ' . $additionalContent . ' '; +$fieldOutput = [ + 'fieldContent' => $phone, + 'fieldId' => $phoneId, + 'fieldName' => $phoneName, + 'fieldTwSelectorsData' => $phoneTwSelectorsData, + 'fieldTypeInternal' => FormsHelper::getStateFieldType('phone'), + 'fieldIsRequired' => $phoneIsRequired, + 'fieldDisabled' => !empty($phoneIsDisabled), + 'fieldTypeCustom' => $phoneTypeCustom ?: 'phone', // phpcs:ignore WordPress.PHP.DisallowShortTernary.Found + 'fieldTracking' => $phoneTracking, + 'fieldConditionalTags' => Helpers::render( + 'conditional-tags', + Helpers::props('conditionalTags', $attributes) + ), + 'fieldAttrs' => $phoneFieldAttrs, +]; + +// Hide label if needed but separated like this so we can utilize normal fieldHideLabel attribute from field component. +if ($phoneHideLabel) { + $fieldOutput['fieldHideLabel'] = true; +} + echo Helpers::render( 'field', array_merge( - Helpers::props('field', $attributes, [ - 'fieldContent' => $phone, - 'fieldId' => $phoneId, - 'fieldName' => $phoneName, - 'fieldTwSelectorsData' => $phoneTwSelectorsData, - 'fieldTypeInternal' => FormsHelper::getStateFieldType('phone'), - 'fieldIsRequired' => $phoneIsRequired, - 'fieldDisabled' => !empty($phoneIsDisabled), - 'fieldTypeCustom' => $phoneTypeCustom ?: 'phone', // phpcs:ignore WordPress.PHP.DisallowShortTernary.Found - 'fieldTracking' => $phoneTracking, - 'fieldHideLabel' => $phoneHideLabel, - 'fieldConditionalTags' => Helpers::render( - 'conditional-tags', - Helpers::props('conditionalTags', $attributes) - ), - 'fieldAttrs' => $phoneFieldAttrs, - ]), + Helpers::props('field', $attributes, $fieldOutput), [ 'additionalFieldClass' => $attributes['additionalFieldClass'] ?? '', 'selectorClass' => $manifest['componentName'] ?? '' diff --git a/src/Blocks/components/rating/rating.php b/src/Blocks/components/rating/rating.php index 6c62d435a..ef5bc3f27 100644 --- a/src/Blocks/components/rating/rating.php +++ b/src/Blocks/components/rating/rating.php @@ -31,7 +31,6 @@ $ratingAmount = Helpers::checkAttr('ratingAmount', $attributes, $manifest); $ratingSingleSubmit = Helpers::checkAttr('ratingSingleSubmit', $attributes, $manifest); $ratingTwSelectorsData = Helpers::checkAttr('ratingTwSelectorsData', $attributes, $manifest); -$ratingHideLabel = false; $ratingId = $ratingName . '-' . Helpers::getUnique(); @@ -98,26 +97,27 @@ class="' . esc_attr(FormsHelper::getTwPart($twClasses, 'rating', 'star', "{$comp ' . $additionalContent . ' '; +$fieldOutput = [ + 'fieldContent' => $rating, + 'fieldId' => $ratingId, + 'fieldName' => $ratingName, + 'fieldTwSelectorsData' => $ratingTwSelectorsData, + 'fieldTypeInternal' => FormsHelper::getStateFieldType('rating'), + 'fieldIsRequired' => $ratingIsRequired, + 'fieldDisabled' => !empty($ratingIsDisabled), + 'fieldTypeCustom' => $ratingTypeCustom ?: 'rating', // phpcs:ignore WordPress.PHP.DisallowShortTernary.Found + 'fieldTracking' => $ratingTracking, + 'fieldConditionalTags' => Helpers::render( + 'conditional-tags', + Helpers::props('conditionalTags', $attributes) + ), + 'fieldAttrs' => array_merge($ratingFieldAttrs, ['role' => 'radiogroup']), +]; + echo Helpers::render( 'field', array_merge( - Helpers::props('field', $attributes, [ - 'fieldContent' => $rating, - 'fieldId' => $ratingId, - 'fieldName' => $ratingName, - 'fieldTwSelectorsData' => $ratingTwSelectorsData, - 'fieldTypeInternal' => FormsHelper::getStateFieldType('rating'), - 'fieldIsRequired' => $ratingIsRequired, - 'fieldDisabled' => !empty($ratingIsDisabled), - 'fieldTypeCustom' => $ratingTypeCustom ?: 'rating', // phpcs:ignore WordPress.PHP.DisallowShortTernary.Found - 'fieldTracking' => $ratingTracking, - 'fieldHideLabel' => $ratingHideLabel, - 'fieldConditionalTags' => Helpers::render( - 'conditional-tags', - Helpers::props('conditionalTags', $attributes) - ), - 'fieldAttrs' => array_merge($ratingFieldAttrs, ['role' => 'radiogroup']), - ]), + Helpers::props('field', $attributes, $fieldOutput), [ 'additionalFieldClass' => $attributes['additionalFieldClass'] ?? '', 'selectorClass' => $manifest['componentName'] ?? '' diff --git a/src/Blocks/components/textarea/textarea.php b/src/Blocks/components/textarea/textarea.php index faa527ed3..e78177d89 100644 --- a/src/Blocks/components/textarea/textarea.php +++ b/src/Blocks/components/textarea/textarea.php @@ -90,26 +90,32 @@ class="' . esc_attr($textareaClass) . '" ' . $additionalContent . ' '; +$fieldOutput = [ + 'fieldContent' => $textarea, + 'fieldId' => $textareaId, + 'fieldName' => $textareaName, + 'fieldTwSelectorsData' => $textareaTwSelectorsData, + 'fieldTypeInternal' => FormsHelper::getStateFieldType('textarea'), + 'fieldIsRequired' => $textareaIsRequired, + 'fieldDisabled' => !empty($textareaIsDisabled), + 'fieldTypeCustom' => $textareaTypeCustom ?: 'textarea', // phpcs:ignore WordPress.PHP.DisallowShortTernary.Found + 'fieldTracking' => $textareaTracking, + 'fieldConditionalTags' => Helpers::render( + 'conditional-tags', + Helpers::props('conditionalTags', $attributes) + ), + 'fieldAttrs' => $textareaFieldAttrs, +]; + +// Hide label if needed but separated like this so we can utilize normal fieldHideLabel attribute from field component. +if ($textareaHideLabel) { + $fieldOutput['fieldHideLabel'] = true; +} + echo Helpers::render( 'field', array_merge( - Helpers::props('field', $attributes, [ - 'fieldContent' => $textarea, - 'fieldId' => $textareaId, - 'fieldName' => $textareaName, - 'fieldTwSelectorsData' => $textareaTwSelectorsData, - 'fieldTypeInternal' => FormsHelper::getStateFieldType('textarea'), - 'fieldIsRequired' => $textareaIsRequired, - 'fieldDisabled' => !empty($textareaIsDisabled), - 'fieldTypeCustom' => $textareaTypeCustom ?: 'textarea', // phpcs:ignore WordPress.PHP.DisallowShortTernary.Found - 'fieldTracking' => $textareaTracking, - 'fieldHideLabel' => $textareaHideLabel, - 'fieldConditionalTags' => Helpers::render( - 'conditional-tags', - Helpers::props('conditionalTags', $attributes) - ), - 'fieldAttrs' => $textareaFieldAttrs, - ]), + Helpers::props('field', $attributes, $fieldOutput), [ 'additionalFieldClass' => $attributes['additionalFieldClass'] ?? '', 'selectorClass' => $manifest['componentName'] ?? '',