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

Contact form loses data after postback with error (ex. captcha not entered) on 3.7.3 (with maybe solution) #17126

Closed
pascal-910 opened this issue Jul 13, 2017 · 12 comments

Comments

@pascal-910
Copy link

pascal-910 commented Jul 13, 2017

Steps to reproduce the issue

Fresh install of joomla 3.7.3

  1. Add a new Contact
    a. linked to Super user
  2. Add a new Menu item of type „Single contact“ and select added contact from step 1
  3. Extensions – Plugins
    a. Enable „Captcha – ReCaptcha“ Plugin
    b. Go to Plugin configuration and enter dummy string into „Site key“ and „Secret Key“ (for ex. „xxx“)
  4. Global Configuration – Site – Default Captcha: Set to „ReCaptcha“
  5. Go to front-end and select menu created in step 2)
    Then select „Contact form“ and enter something into “Name”, “Email”, “Subject” and “Message” field. Then press “Send Email”

Expected result

Postback, then message box that captcha wasn't set and still filled Textboxes

Actual result

Postback with messagebox, but all textboxes are empty so user has to enter again everything

System information (as much as possible)

Problem didn't occur before 3.7.3
PHP 5.4.16
Win7 Business Edition SP1
Apache 2.4.4.
Mysql 5.0.10

Additional comments

Hint to solution/reason:

I don’t know what’s the line for but in file “components\com_contact\views\contact\view.html.php” line 75 the contact data will be overwritten with category id. If this line is commented out it works. You can enter something in contact form, if you don’t enter captcha data and submit no data will be lost in textboxes and user don’t need to enter again.

$app->setUserState('com_contact.contact.data', array('catid' => $item->catid));

@infograf768
Copy link
Member

Please test #17122


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17126.

@sandewt
Copy link
Contributor

sandewt commented Jul 18, 2017

I use my own simple captcha plugin.
If I entered data in the contact form and do not fill in correctly the captcha field, all form data loses after a post.
Problem didn't occur certainly in J3.7.0.
#17122 test negative.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17126.

@sandewt
Copy link
Contributor

sandewt commented Jul 18, 2017

Additional comment:

See also: Additional comments pascal-910 (13 july)

If I delete the line 75: $app->setUserState('com_contact.contact.data', array('catid' => $item->catid));
No data in contact form data loses. That's OK.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17126.

@tonypartridge
Copy link
Contributor

You shouldn't delete the line but instead use a getfromstate request in there and if it doesn't exists it sets $itsm->catid

@sandewt
Copy link
Contributor

sandewt commented Jul 27, 2017

With var_dump($item) you can see that $item->catid is already loaded. So it exists.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17126.

@sandewt
Copy link
Contributor

sandewt commented Aug 28, 2017

Hi @tonypartridge,

Do you mean the following?

Change line 75 (..a\components\com_contact\views\contact\view.html.php))

$app->setUserState('com_contact.contact.data', array('catid' => $item->catid));

To

if (!isset($item->catid) || empty($item->catid))
{	
   $app->setUserState('com_contact.contact.data', array('catid' => $item->catid));
}

If I tested local, its works by the 'Single Contact' form + captcha enabled.

Gr.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17126.

@tonypartridge
Copy link
Contributor

That looks good to me Gr, can you do a pull request?

@sandewt
Copy link
Contributor

sandewt commented Aug 28, 2017

I have made my first pull request #17743.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17126.

@joomla-cms-bot
Copy link

Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/17126

@ghost
Copy link

ghost commented Aug 28, 2017

closed as having Pull Request #17743


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17126.

@sandewt
Copy link
Contributor

sandewt commented Dec 16, 2017

Hi @franz-wohlkoenig, Pull Request #17743 is still open for testing.

@ghost
Copy link

ghost commented Dec 16, 2017

have called 2 former Testers for retest.

mbabker pushed a commit that referenced this issue Jan 8, 2018
* Contact form loses data after postback with error

Pull Request for issue #17126.

Testing Instructions. See issue #17126
* Go to Single Contact. 
* Fill in the form. 
* Do not fill in captcha.
* Send email.

Expected result:  
Warning + textboxes are NOT empty. 
So the user should not entered all text again.

Actual result:
All textboxes are empty, so the user has to enter again all textboxes.

Thanks to: 
@ pascal-910.

* Delete some tabs

Delete some tabs.

* Update view.html.php

if (!isset($item->catid) || empty($item->catid)) changes to if (empty($item->catid))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants