Skip Navigation

[Resolved] Split: Validation of image field in the user form in toolset

This support ticket is created 3 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 17 replies, has 2 voices.

Last updated by Shane 3 years, 6 months ago.

Assisted by: Shane.

Author
Posts
#1911113

Hi Shane,

Tested the image validation in hidden link and it is working fine. Many thanks.

However, I'm not sure why the form is allowed to submit when there are errors in the image field.

Also, not sure whether this is a bug for this field as I'm sure looking at the existing tickets, these kind of validations are requested by many and none of them found it as an issue?

I'm happy to have a new ticket but would be good if it is handled by you since I do not need to go through these for one more time.

Thanks.

#1911115

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

I've split the ticket here, so we can handle this issue separately.

#1911123

Thanks Shane,

Waiting for your update.

To reiterate the issue, image fields in post form and user form are able to submit (Click twice) after validation of the images (dimension and size) is done and not meeting the validation criteria.

Thanks.

#1911195

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

I can also confirm that this issue occurs on a clean install as well, so i'm making a report of the issue.

Our second tier supporters will provide an update on this as the steps forward.

Thanks,
Shane

#1911717

Hi Shane,

Thanks. To inform you that I would need the fix as early as possible.

Thanks.

#1913391

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

Our team is working on fixing the underlying issue for this.

However you should be able to block the form from submitting by adding this if statement to it.


      if(empty($_FILES['wpcf-property-image-one']['tmp_name'])){
    $errors['property-image-one'] = __("Please re-upload your image");
  }
    if(empty($_FILES['wpcf-property-image-two']['tmp_name'])){
    $errors['property-image-two'] = __("Please re-upload your image");
  }
    if(empty($_FILES['wpcf-property-image-three']['tmp_name'])){
    $errors['property-image-three'] = __("Please re-upload your image");
  }

Please let me know if this helps.
Thanks,
Shane

#1915187

Hi Shane,

Added the code provided by you but not working as expected.

Tested in page "hidden link" with the below steps:

1. Code snippet "post_form_image_validation" - Reduced the file size to 1024 KB for image one (1. Property Image One) only and remaining are with more than 5 MB.
2. Added images in fields "1. Property Image One", "2. Property Image Two" and "3. Property Image Three" with image files more than 1 MB.
3. After clicking the submit button it says, the file size for "1. Property Image One" is more than 1 MB which is expected.
4. After clicking the submit button one more time without correcting the images, it is showing the below error for all the image fields.

Property Image One: Please re-upload your image
Property Image Two: Please re-upload your image
Property Image Three: Please re-upload your image

Although the fields "Property Image Two" and "Property Image Three" contains the correct images with all the conditions met, still the above errors are showing.

Please suggest me.

Thanks.

#1915213

Hi Shane,

Please refer to code snippet "post_form_image_validation" with the admin credentials provided as a part of earlier ticket and suggest the correction.

Thanks.

#1915235

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

The code is actually working correctly,

The main issue is that on our end and this was escalated is that the fields should be cleared after a failed validation.

Given that its the default php upload then no files were uploaded so the items needed to be re-attached. So its working correctly because after a failed submit all the upload fields will lose their values.

I hope this clarifies the issue for you.

Thanks,
Shane

#1915295

Hi Shane,

Many thanks for your quick reply as always.

I understand what you are trying to say technically.

But when the user submits the images, let's take the same example while they submit the size more than expected (more than MB) for only one image field, and the error message shows to upload the new image for all the image fields (second image filed & third image field) it will not be a good user experience.

I do not want user to re upload every image when the validation is failed only for one image.

Please suggest me.

Thanks.

#1915331

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

This is exactly the case, not much else we can do because they will need to re-upload back all the images because of how the php default upload works.

The only way I can think of working around this is to use the AJAX upload which will give them the media library interface to upload the images and the verification would happen immediately on upload.

Our development team is working on fixing the issue with the php upload not clearing the fields. What should happen is that after the failed submit all your uploaded images need to be re-uploaded, hence why when you submit the form again after the failed validation.

The fields are actually still empty even though you see the filename below the field.

Thanks,
Shane

#1915337

Hi Shane,

Ajax validation is not a requirement for me considering the interface.

Please suggest by when we can expect a fix from your development team.

A quick install might help more because almost all the website is done expect these one or two issues related to image fields.

Thanks.

#1915407

Hi Shane,

Please add this fix into the current release which I might expect 2 to 3 weeks.

This is something which is missing in core and seems would need a fix as soon as possible.

I would need an urgent fix to this issue, please update me on the ETA.

Thanks.

#1917611

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

I actually dont have good news on this one. While the devs are aware of this issue and its been discussed on.

I'm not seeing where they have proposed a timeline for the fix so I cannot give any guarantees as to when this will fix.

My advise here until this is fixed is to provide an adequate feedback the users so they know that they will need to re-upload all the images after a failed validation.

Thanks,
Shane

#1919349

Hi Shane,

Initially I have planned to create this section using image field (repeated), there is some issue "Validate the image field (Repeating) in the Post Form in Tool set" due to which I have changed to image fields (non repeated) for time being.

However, there is an issue again in this field as well which is very unfortunate.

Instructing customers to re-upload the images is a poor customer experience.

Please inform to the development team and let me know the ETA please.

Thanks,
Pramod.