YAML Form file upload or document upload fields are not working since the beta-25 update. I have also tested development versions and they do not work either. If an upload field is present on the form it does not submit and keeps refreshing the page with all of the information. No log is made of any error. I had the captcha module on, but turning it off makes no difference.

To reproduce try the job application template provided with YamlForm.

Issue fork webform-2833759

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

asad.hasan created an issue. See original summary.

jrockowitz’s picture

Priority: Critical » Major
Status: Active » Postponed (maintainer needs more info)

I can't reproduce this issue via the latest dev release.

These are the steps I am taking to try to reproduce this issue.

  • Login as form admin
  • Duplicate the Job template. (/admin/structure/yamlform/manage/template_job_application/duplicate)
  • Submit the new job template. (/form/job-application)
  • Confirm that the form was submitted. (/form/job-application/confirmation)
asad.hasan’s picture

Thanks for your reply @jrockowitz

Here is the yaml source for the form in question. Even though I have made the upload field a flat field with no need to select resume type in this version, it didn't work in its original configuration:

information:
  '#title': 'Your Information'
  '#type': fieldset
  first_name:
    '#title': 'First Name'
    '#type': textfield
    '#required': true
  middle_initial:
    '#type': textfield
    '#title': 'Middle Initial'
    '#title_display': before
  last_name:
    '#title': 'Last Name'
    '#type': textfield
    '#required': true
contact_information:
  '#title': 'Contact Information'
  '#type': fieldset
  email:
    '#type': email
    '#title': Email
    '#required': true
  phone:
    '#type': tel
    '#title': Phone
    '#required': true
resume:
  '#title': 'Your Resume'
  '#type': fieldset
  paste_your_resume:
    '#type': textarea
    '#title': 'Paste your resume'
  upload_resume:
    '#type': document_file
    '#title': 'Upload Resume'
additional_information:
  '#type': fieldset
  '#title': Questions
  are_you_legally_authorized_to_work_in_the_united_states_:
    '#type': radios
    '#title': 'Are you legally authorized to work in the United States?'
    '#options': yes_no
    '#options_display': side_by_side
  where_did_you_hear_about_empower_pharmacy:
    '#type': select_other
    '#title': 'Where did you hear about Empower Pharmacy?'
    '#options':
      Job_Board: 'Job Board'
      Website: Website
      LinkedIn: LinkedIn
      Referral: Referral
  are_you_currently_registered_with_the_state_board_of_pharmacy_:
    '#type': radios
    '#title': 'Are you currently registered with the State Board of Pharmacy?'
    '#options': yes_no
    '#options_display': side_by_side
  are_you_certified_pharmacy_technician_cpht_by_the_pharmacy_techn:
    '#type': radios
    '#title': 'Are you Certified Pharmacy Technician (CPht) by the Pharmacy Technician Certification Board?'
    '#options': yes_no
    '#options_display': side_by_side
  do_you_have_at_least_two_years_experience_in_pharmacy_:
    '#type': radios
    '#title': 'Do you have at least two years experience in Pharmacy?'
    '#options': yes_no
    '#options_display': side_by_side
self_identification_questions:
  '#type': fieldset
  '#title': 'Voluntary Self-Identification Questions'
  race_ethnicity:
    '#type': radios
    '#title': Race/Ethnicity
    '#options':
      American_Indian_or_Alaska_Native: 'American Indian or Alaska Native'
      Asian: Asian
      Black_or_African_American: 'Black or African American'
      Hispanic_or_Latino: 'Hispanic or Latino'
      White_or_Caucasian: 'White or Caucasian'
      Two_or_More_Races: 'Two or More Races'
      I_prefer_not_to_answer: 'I prefer not to answer'
  gender:
    '#type': radios
    '#title': Gender
    '#options':
      Female: Female
      Male: Male
      I_prefer_not_to_answer: 'I prefer not to answer'
  veteran_status:
    '#type': radios
    '#title': 'Veteran Status'
    '#options':
      I_am_a_protected_veteran: 'I am a protected veteran'
      I_am_not_a_protected_veteran: 'I am not a protected veteran'
      I_prefer_not_to_answer: 'I prefer not to answer'
  please_select_one_of_the_options_below_:
    '#type': radios
    '#title': Disability
    '#options':
      'No_,_I_Do_Not_Have_a_Disability': 'No, I Do Not Have a Disability'
      'Yes_,_I_Do_Have_a_Disability': 'Yes, I Do Have a Disability'
      I_Do_Not_Wish_To_Answer: 'I Do Not Wish To Answer'
applied_job_link:
  '#type': hidden
  '#value': '<strong>Job Applied:</strong> <a href="[current-page:url]">[current-page:url]</a>'
jrockowitz’s picture

Your form works fine for me.

Do you have the private files directory configured?

Is there anything being logged (/admin/reports/dblog) or in the Status Report (/admin/reports/status).

jrockowitz’s picture

asad.hasan’s picture

I will try to replicate it with that site. There is nothing being logged in the status report.

jrockowitz’s picture

Project: YAML Form » Webform
Version: 8.x-1.0-beta25 » 8.x-5.x-dev
jrockowitz’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
JeroenT’s picture

Status: Closed (cannot reproduce) » Active

I can reproduce this error. In my theme the template input--submit.html.twig was overriden and the HTML of the buttons was changed from to

JeroenT’s picture

To reproduce this error:

Create a webform with an upload field.

In your theme override the input--submit.html.twig to something like:

   {% set value = attributes.value %}
  <button{{ attributes|without('value') }}>{{ value }}</button>

When you try to submit the webform now, the page refreshes and nothing happens.

In the validate function of the webform, the triggering element is the upload button of the file field.

Not sure if this is a webform bug or a drupal core bug.

jrockowitz’s picture

The Webform module is just using core's ManagedFile element with a little extra code to convert the uploaded File entity to just the file's fid when the uploaded file is saved to the DB.

@JeroenT What theme/base theme are you using?

JeroenT’s picture

@jrockowitz,

I'm using a custom build theme. That's why the button templates were overridden.

jrockowitz’s picture

I think this is a core bug. Can you reproduce this issue using core's Contact module with a file field.?

JeroenT’s picture

I was unable to reproduce this bug using core's contact module.

jrockowitz’s picture

Status: Active » Closed (works as designed)

If more people have theme related issues, we might need to create a documentation page to address these specific and ongoing issues.

KilianM’s picture

I got the same problem on my form :

agence_mail:
  '#type': select
  '#title': Agence
  '#options':
    - Empty
  '#required': true
agence_name:
  '#type': hidden
nom:
  '#type': textfield
  '#title': Nom
  '#required': true
prenom:
  '#type': textfield
  '#title': Prénom
  '#required': true
telephone:
  '#type': textfield
  '#title': Téléphone
  '#size': '10'
  '#maxlength': '10'
  '#input_mask': '9999999999'
  '#required': true
  '#pattern': '[0-9]{10}'
email:
  '#type': email
  '#title': Email
  '#required': true
profil:
  '#type': radios
  '#title': Profil
  '#default_value': '1'
  '#options':
    1: Particulier
    2: Professionnel
  '#options_display': two_columns
  '#required': true
professionnel:
  '#type': fieldset
  '#title': Professionnel
  '#states':
    invisible:
      ':input[name="profil"]':
        value: '1'
  entreprise:
    '#type': textfield
    '#title': Entreprise
    '#states':
      required:
        ':input[name="profil"]':
          value: '2'
  siren:
    '#type': textfield
    '#title': SIREN
    '#size': '11'
    '#maxlength': '11'
    '#input_mask': '999999999'
    '#states':
      required:
        ':input[name="profil"]':
          value: '2'
type_de_la_demande:
  '#type': select
  '#title': 'Type de la demande'
  '#options':
    - Devis
    - Renseignements
    - Produits
  '#empty_option': 'Choisir un type de demande'
  '#required': true
titre_du_projet:
  '#type': textfield
  '#title': 'Titre du projet'
  '#required': true
votre_message:
  '#type': textarea
  '#title': 'Description du projet'
  '#required': true
piece_jointe:
  '#type': document_file
  '#title': 'Pièce jointe'
  '#max_filesize': '2'
  '#file_extensions': 'jpg png pdf doc docx jpeg xls'
secu_projet:
  '#type': captcha
mail:
  '#type': hidden

If I remove document_file or enable ajax on the form i got no problem.

I use a custom theme but I don't override the webform templates.

jrockowitz’s picture

Are you still seeing the issue with just...

piece_jointe:
  '#type': document_file
  '#title': 'Pièce jointe'
  '#max_filesize': '2'
  '#file_extensions': 'jpg png pdf doc docx jpeg xls'

Are you able to replicate this issue using the Bartik theme?

If your custom theme is causing the problem, you need to fix your custom theme.

KilianM’s picture

I have the same problem with just the document file element only and the bartik theme.

Theme: Bartik 8.5.1
Drupal: 8.5.1
Webform: 8.x-5.0-rc10+10-dev

jrockowitz’s picture

Status: Closed (works as designed) » Postponed (maintainer needs more info)

Are you able to replicate the problem via https://simplytest.me?

KilianM’s picture

Can we configure private files on simplytest ?

I just tried to remove all custom modules and themes and I still have the same error.
Locally with a new Drupal I don't have the error though.
Could this be due to an update of the module ?
I created this form with Webform 8.x-5.0-beta11
I will try to uninstall all contribution modules to see if there is a conflict.

KilianM’s picture

OK so even after removing all the contribution modules, custom themes and custom modules I still have the error.
I can send you the code and db for testing if needed.

jrockowitz’s picture

Please do not send me your DB. I just need to know how to replicate the issue.

jrockowitz’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Marking as can't reproduce. Please reopen with an example webform and configuration that can be used to reproduce this issue.

jayprakash.kushwah made their first commit to this issue’s fork.