No Code Attached Yet bug
avatar Flowman
Flowman
21 Jul 2024

Steps to reproduce the issue

Kind of hard to explain. I am making a 3-party component that using the EmailRule to check for unique="true".

On save it will always fail with "Exception has occurred. UnexpectedValueException: The email address you entered is already in use. Please enter another email address."

The issue is that in the FormController in the save function we are not loading the form data. So when we get to the validation, the form data is always empty but the EmailRule is checking for form data to validate uniqueness.

The fix for it is to change:

$userId = ($form instanceof Form) ? (int) $form->getValue('id') : 0;

to

$userId = (int) $input->get('id', 0); 

This will check the submitted data instead of the form load data.

Expected result

Be able to validate unique email

Actual result

Exception has occurred.
UnexpectedValueException: The email address you entered is already in use. Please enter another email address.

System information (as much as possible)

dbserver: mysql
dbversion: 8.0.21-12.1
phpversion: 8.3.8
server: nginx/1.25.4
version: Joomla! 5.1.1 Stable [ Kudumisha ] 28-May-2024 16:00 GMT

Additional comments

avatar Flowman Flowman - open - 21 Jul 2024
avatar joomla-cms-bot joomla-cms-bot - change - 21 Jul 2024
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 21 Jul 2024
avatar Fedik Fedik - change - 22 Jul 2024
Labels Added: bug
avatar Fedik Fedik - labeled - 22 Jul 2024
avatar Fedik
Fedik - comment - 22 Jul 2024

As you know a fix, can you make a PR?

avatar HLeithner
HLeithner - comment - 22 Jul 2024

please check that $input is not null when creating the PR

avatar richard67 richard67 - change - 22 Jul 2024
Status New Closed
Closed_Date 0000-00-00 00:00:00 2024-07-22 14:22:17
Closed_By richard67
avatar richard67 richard67 - close - 22 Jul 2024
avatar richard67
richard67 - comment - 22 Jul 2024

Closing as having a pull request. See #43822 .

Add a Comment

Login with GitHub to post a comment