Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with the form widget / checkbox #868

Closed
jam1974 opened this issue Nov 12, 2024 · 24 comments · Fixed by #853
Closed

Problem with the form widget / checkbox #868

jam1974 opened this issue Nov 12, 2024 · 24 comments · Fixed by #853
Labels
bug Something isn't working
Milestone

Comments

@jam1974
Copy link

jam1974 commented Nov 12, 2024

When selecting a checkbox with the property Mandatory, the dispatch works even if the box is not activated.

@felixkat
Copy link

Hi,

Which Astroid version is this running?

Does this happen with all elements for Mandatory \ Field required?

Apart from the issue, does the form work correctly and send emails? (asking the question due to a different logged issue).

@jam1974
Copy link
Author

jam1974 commented Nov 12, 2024

I am running version 3.1.7 and the form only shows the checkbox. If there is no entry in the fields for text, textarea, or email and these are also declared as mandatory fields, there is a message when sending that the fields require an entry. The form is submitted correctly.

I have just noticed that my entry is under "Success & Error Message Options" does not work either. When sending, the original text “Message sent successfully!” remains. However, I have stored my texts in the backend.
form_checkbox

@felixkat
Copy link

felixkat commented Nov 12, 2024

Thank you for the update and video, it makes your issue clearer.

I will try and replicate your issue but I having a slight issue in getting my form working #867

EDIT:- Which Joomla version are you running?

@jam1974
Copy link
Author

jam1974 commented Nov 12, 2024

I'm working with J5.2.1.

@jam1974
Copy link
Author

jam1974 commented Nov 12, 2024

I have tested it. The error also occurs in the following field types: Radio, Select, Range

@felixkat
Copy link

Well the good news is you have partially assisted in getting my test form working. I took a different approach on the basis of knowing that the basic process of your form is working.

I will replicate and test your setup later.

@jam1974
Copy link
Author

jam1974 commented Nov 12, 2024

I have read this #867 (comment) I have also integrated the form in the layout and not via the articles. I simply assigned the widget to the corresponding menu item.

@sonvnn
Copy link
Member

sonvnn commented Nov 13, 2024

Thank you I will check it and response asap 👍

@felixkat
Copy link

I have just noticed that my entry is under "Success & Error Message Options" does not work either. When sending, the original text “Message sent successfully!” remains. However, I have stored my texts in the backend.

@sonvnn For this one Lines 147-148 Need to be changed to in formbuilder/ajax.php


$message_success    =   $params->get('form_submit_success', Text::_('ASTROID_FORMBUILDER_SENT_SUCCESSFULLY'));
$message_failed     =   $params->get('form_submit_failed', Text::_('ASTROID_FORMBUILDER_SENT_MAIL_FAILED'));

@sonvnn
Copy link
Member

sonvnn commented Nov 13, 2024

I have just noticed that my entry is under "Success & Error Message Options" does not work either. When sending, the original text “Message sent successfully!” remains. However, I have stored my texts in the backend.

@sonvnn For this one Lines 147-148 Need to be changed to in formbuilder/ajax.php


$message_success    =   $params->get('form_submit_success', Text::_('ASTROID_FORMBUILDER_SENT_SUCCESSFULLY'));
$message_failed     =   $params->get('form_submit_failed', Text::_('ASTROID_FORMBUILDER_SENT_MAIL_FAILED'));

Thanks, you can create a pull request. I will check and merge it to the master branch :)

@felixkat
Copy link

When selecting a checkbox with the property Mandatory, the dispatch works even if the box is not activated.

@jam1974 I can recreate this issue, a quick look suggests that there isn't any code implemented for the checkbox and radio options to make this work.

For the select, I don't think we can do much as something is always selected, ideally we need something like a "please select" which has no value, so it won't proceed unless something is selected.

I'll put a pull request in for the success and error message but you can test this yourself if you want to manually try it. #868 (comment)

@jam1974
Copy link
Author

jam1974 commented Nov 13, 2024

@felixkat #868 (comment) works. For the checkbox, I don't think it's a solution if I select “Please select”. I think about a function for the PrivacyCheckbox. Okay, maybe you need a new form type for this.

@felixkat
Copy link

@felixkat #868 (comment) works. For the checkbox, I don't think it's a solution if I select “Please select”. I think about a function for the PrivacyCheckbox. Okay, maybe you need a new form type for this.

Yes I understand, for the Privacy Checkbox it should be a checkbox or radio, I will try and look at the code later.

But in other situations that require a selection before proceeding a "Please select" would be useful otherwise it will always use the default.

@jam1974
Copy link
Author

jam1974 commented Nov 14, 2024

@felixkat I do not consider a selection for confirmation to be useful in this case. Today I tried to integrate a function that can be activated like the forwarding url or the captcha. When I activate it, I get a field in which I can enter the desired text. And if this is activated, the sending of the email is blocked in the form as long as the checkbox is not selected. but my knowledge is probably not sufficient.

@felixkat
Copy link

I do not consider a selection for confirmation to be useful in this case

I agree, I was just thinking about other cases where this may be useful. Ideally the function needs to work with all fields.

Today I tried to integrate a function that can be activated like the forwarding url or the captcha. When I activate it, I get a field in which I can enter the desired text. And if this is activated, the sending of the email is blocked in the form as long as the checkbox is not selected. but my knowledge is probably not sufficient.

The check \ radio needs to be modified to prevent form submission if the boxes are not checked. I will try and take a look later or maybe @sonvnn

@felixkat
Copy link

@jam1974 I've made the changes to check boxes and radio

You can download formbuilder.php here to test.

https://github.com/felixkat/astroid-framework/blob/e62bfce83e3954aa7fac4720b4b75236215bdd20/framework/elements/formbuilder/formbuilder.php

@jam1974
Copy link
Author

jam1974 commented Nov 14, 2024

@felixkat thanks for the revised code - but now i also get the message: undefined

@felixkat
Copy link

What version or commit are you on? I think Sonny has made some changes today which may not yet be complete.

If you are on today's commit you can download the following file as well to keep everything in sync.

https://github.com/felixkat/astroid-framework/blob/e62bfce83e3954aa7fac4720b4b75236215bdd20/framework/elements/formbuilder/ajax.php

@sonvnn
Copy link
Member

sonvnn commented Nov 15, 2024

The issue from this $element = Helper::getElement($unqid); It happens when load a form in Article Layout and cause is system can not reconize the $template. I am working on it. Please wait for the update.

@jam1974
Copy link
Author

jam1974 commented Nov 15, 2024

@sonvnn I have integrated the form in the layout and not via the articles layout. The widget is assigned to a menu item.

@felixkat
Copy link

@jam1974 The code Sonny is working on isn't completed yet, so may break if you use the latest commit, even with layout.

If you use the two links I posted earlier it should work until Sonny has a chance to finish. Just download the two files only, (not the whole zip file), and replace your existing ones.

sonvnn added a commit that referenced this issue Nov 15, 2024
@sonvnn
Copy link
Member

sonvnn commented Nov 15, 2024

@felixkat @jam1974 I fixed this issue at 0a0433a Please help me download v3-branch and check it.

Thanks & Best Regards,
Sonny

@jam1974
Copy link
Author

jam1974 commented Nov 15, 2024

The formbuilder.php (https://github.com/felixkat/astroid-framework/blob/e62bfce83e3954aa7fac4720b4b75236215bdd20/framework/elements/formbuilder/formbuilder.php) thanks @felixkat in combination with the v3 (0a0433a) thanks @sonvnn fixes the problem. Email is now only sent if the checkbox is activated.

@felixkat
Copy link

Thanks for testing @jam1974. I'll submit a fix for the checkbox, I'll let you know when it's in the main code so you can test again.

@sonvnn sonvnn added the bug Something isn't working label Nov 22, 2024
@sonvnn sonvnn added this to the Version 3.1.8 milestone Nov 22, 2024
@sonvnn sonvnn linked a pull request Nov 22, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants