solspace / craft-freeform

Freeform for Craft: The most reliable form builder that's ready for wherever your project takes you.
https://docs.solspace.com/craft/freeform/v5/
Other
47 stars 60 forks source link

Error with Entry-Integration and Checkbox-Group (Checkboxes) #1303

Closed BlueElefant closed 5 months ago

BlueElefant commented 5 months ago

What happened?

An error occurs when trying to use an entry-integration on an form with a checkbox-group aka checkboxes (with just one checkbox as an option) and trying to map (via attribute mapping in the integrations tab) to an lightswitch-field in an entry leading to an error after submitting the form.

Errors and Stack Trace (if available)

Exception 'TypeError' with message 'strtolower(): Argument #1 ($string) must be of type string, array given' 

in /var/www/clients/client1/web10/web/vendor/solspace/craft-freeform/packages/plugin/src/Bundles/Integrations/Elements/ValueTransformers/BooleanValueTransformer.php:28

Stack trace:
#0 /var/www/clients/client1/web10/web/vendor/solspace/craft-freeform/packages/plugin/src/Bundles/Integrations/Elements/ValueTransformers/BooleanValueTransformer.php(28): strtolower()
#1 [internal function]: Solspace\Freeform\Bundles\Integrations\Elements\ValueTransformers\BooleanValueTransformer->transformValue()
#2 /var/www/clients/client1/web10/web/vendor/yiisoft/yii2/base/Event.php(312): call_user_func()
#3 /var/www/clients/client1/web10/web/vendor/solspace/craft-freeform/packages/plugin/src/Library/Integrations/Types/Elements/ElementIntegration.php(78): yii\base\Event::trigger()
#4 /var/www/clients/client1/web10/web/vendor/solspace/craft-freeform/packages/plugin/src/Integrations/Elements/User/User.php(109): Solspace\Freeform\Library\Integrations\Types\Elements\ElementIntegration->processMapping()
#5 /var/www/clients/client1/web10/web/vendor/solspace/craft-freeform/packages/plugin/src/Integrations/Elements/ElementsBundle.php(71): Solspace\Freeform\Integrations\Elements\User\User->buildElement()
#6 [internal function]: Solspace\Freeform\Integrations\Elements\ElementsBundle->validate()
#7 /var/www/clients/client1/web10/web/vendor/yiisoft/yii2/base/Event.php(312): call_user_func()
#8 /var/www/clients/client1/web10/web/vendor/solspace/craft-freeform/packages/plugin/src/Form/Form.php(869): yii\base\Event::trigger()
#9 /var/www/clients/client1/web10/web/vendor/solspace/craft-freeform/packages/plugin/src/Form/Form.php(550): Solspace\Freeform\Form\Form->validate()
#10 /var/www/clients/client1/web10/web/vendor/solspace/craft-freeform/packages/plugin/src/controllers/SubmitController.php(42): Solspace\Freeform\Form\Form->handleRequest()
#11 [internal function]: Solspace\Freeform\controllers\SubmitController->actionIndex()
#12 /var/www/clients/client1/web10/web/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#13 /var/www/clients/client1/web10/web/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#14 /var/www/clients/client1/web10/web/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction()
#15 /var/www/clients/client1/web10/web/vendor/craftcms/cms/src/web/Application.php(340): yii\base\Module->runAction()
#16 /var/www/clients/client1/web10/web/vendor/craftcms/cms/src/web/Application.php(641): craft\web\Application->runAction()
#17 /var/www/clients/client1/web10/web/vendor/craftcms/cms/src/web/Application.php(302): craft\web\Application->_processActionRequest()
#18 /var/www/clients/client1/web10/web/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest()
#19 /var/www/clients/client1/web10/web/web/index.php(21): yii\base\Application->run()
#20 {main}

How can we reproduce this?

  1. create a form with a checkbox group but only one checkbox as an option
  2. create an elements integration for users
  3. create an lightswitch field in user data
  4. map the checkbox to the lightswitch field
  5. try to submit the form

Freeform Edition

Pro

Freeform Version

5.1.8

Craft Version

Pro 4.9.2

When did this issue start?

After upgrading from older Freeform version

Previous Freeform Version

i.d.k.

kjmartens commented 5 months ago

Sorry for the delay @BlueElefant,

I believe this issue was actually addressed in Freeform 5.1.9 (one version after the one you have currently installed). Can you update to the latest version (now 5.3.1) and see if this is resolved for you? 🙂

I tested this again now and it seems to work fine for me in Freeform 5.3+.

BlueElefant commented 5 months ago

Sorry for the delay @BlueElefant,

I believe this issue was actually addressed in Freeform 5.1.9 (one version after the one you have currently installed). Can you update to the latest version (now 5.3.1) and see if this is resolved for you? 🙂

I tested this again now and it seems to work fine for me in Freeform 5.3+.

Thank you, gonna try it :)