How to download file upon submitting a form?

I have a form with the submit button. And I have a file in ‘/sites/default/files/tmp/my_doc.docx’ I’m trying to download the file upon submitting the form.

Here is my code

public function submitForm(array &$  form, FormStateInterface $  form_state){    $  filename = '/sites/default/files/tmp/my_doc.docx';    $  response = new BinaryFileResponse($  filename);    $  form_state->setResponse($  response); } 

But it doesnt’t work properly.

That is, the file is being downloaded but has the same name that name of php file containing this code.

Could you clarify me, what have I done wrong ?

Send a form to a HTTP server in rails using Unity

i’m trying to use UnityWebRequest to send a form to a Ruby on Rails server, but the error, HTTP/1.1 404 Not Found, keep comming.

My code is here:

public void Update_GI_Score() { StartCoroutine(Update_GI_Score_FORM()); }

 IEnumerator Update_GI_Score_FORM()  {      WWWForm form = new WWWForm();      form.AddField("myField", "myData");      Game game = Singleton.GameInstance;      foreach (Score s in game.scores)      {          form.AddField("name", s.Name);          form.AddField("value", s.rate.ToString());      }      var url = RequestController.Instance.baseURL + "atualiza_score";      UnityWebRequest www = UnityWebRequest.Post(url, form);      yield return www.SendWebRequest();      if (www.isNetworkError || www.isHttpError)      {          Debug.Log(www.error);      }      else      {          Debug.Log("Form upload complete!");      }  } 

In the rails routes i got:

post ‘atualiza_score’, controller: ‘integracao_games’, action: :atualiza_score

so how can i get the form correctly, i need to save the field into a database


Can’t bind to ‘formGroup’ since it isn’t a known property of ‘form’

Angular: 7
Есть компонент для входа в приложение. Получаю ошибку:

Uncaught Error: Template parse errors: Can’t bind to ‘formGroup’ since it isn’t a known property of ‘form’.


<form [formGroup]="loginForm" novalidate (ngSubmit)="authenticate()">     <div class="row m-1">         <div class="col-sm-3 col-md-2 col-lg-1">             <span>Email:</span>         </div>         <div class="col-sm-4">             <input class="form-control"                    placeholder="Email"                    formControlName="email"                    name="email">         </div>     </div>      <div class="row m-1">         <div class="col-sm-3 col-md-2 col-lg-1">             <span>Password:</span>         </div>         <div class="col-sm-4">             <input class="form-control"                    placeholder="Password"                    formControlName="password"                    name="password">         </div>     </div>      <div class="row m-1">         <div class="col">             <button class="btn btn-primary"                     [disabled]="loginForm.invalid">                 Log in             </button>         </div>     </div> </form> 


import { Component, OnInit } from '@angular/core'; import { AuthenticationService } from "../shared/authentication.service"; import { Router } from "@angular/router"; import { FormBuilder, FormGroup, Validators } from "@angular/forms";  @Component({     selector: 'cts-login',     templateUrl: './login.component.html',     styleUrls: ['./login.component.sass'] }) export class LoginComponent implements OnInit {     loginForm: FormGroup;      constructor(private authService: AuthenticationService,                 private formBuilder: FormBuilder) {         this.loginForm ={             email: ['', [Validators.required,]],             password: ['', [Validators.required]]         })     }      ngOnInit() { }      authenticate() {         console.log(this.loginForm);     } } 

Class to create and send a PDF form with attached documents

I’m currently working on building a class to create a PDF form application with attached documents and sending that file to an endpoint in Box Api. I have found extremely difficult managing dependencies in this class. For example, I’m making use of a gem combine_pdf.

This gem has the following capabilities, load into a pdf and parse a file. However this are classes on their own. So instantiating an object pdf = will not give me access to pdf.parse(file) or pdf.load(file). This will not work and therefore I’m there having create a dependency on CombinePDF.parse and CombinePdf.load.

Same goes for using prawn. If I pass @pdf_prawn = If I where to try to add @pdf_prawn(page_size: 'LETTER', margin: 0) this will not work and therefore I’ll have to have a dependency of an external class within my class.

Here is the class I’m trying to get rid of dependencies:

class PDFProducer   attr_reader :box, :pdf_prawn, :pdf, :formstack    FORMSTACK_NAME_PATTERN  = /first \= (.*)\nlast \= (.*)/   PATH_OF_PARSED_PDF_FILE = '/app/tmp/pdfs/'.freeze   PDF_PAGE_WIDTH          = 612   PDF_PAGE_LENGTH         = 792    def initialize(args)     @box       = args.fetch(:box,     @pdf_prawn = args.fetch(:pdf_prawn,     @pdf       = args.fetch(:pdf, )     @formstack = args.fetch(:formstack,   end    # Retrive submission IDs & metadata as JSON array of objects.   # TODO add formstack_submissions_ids and approved_submission   def formstack_submissions     unless @formstack.submissions['status'] == 'error'       submissions = @formstack.submissions['submissions']       approved_submission(submissions).map { |submission| submission.fetch('id') }     else       raise "Formstack: #{@formstack.submissions['error']}"     end   end    def approved_submission(submissions) do |submission|       submission['approval_status'] == 'Approved'     end   end    def parse_into_scrie_pdf     formstack_submissions_from_id       .map { |submission| pdf_scrie_application(submission) }   end    def formstack_submissions_from_id { |id| formstack_submission(id) }   end    # GET user data by submission ID   def formstack_submission(submission_id)     @formstack.submission(submission_id)   end    def formstack_fields     @formstack.create_form   end    # Using user Submission JSON, populate PDF form with the user's data.   # Create a CombinePDF object to create a PDF package application   # get attachements from submission by downloading from Box.   # convert image into string using StringIO to be able to use Prawn.   # With Prawn convert the image to PDF and add to PDF package (CombinePDF).   def pdf_scrie_application(submission)     user_data = submission['data']     file_name = name_file(submission)     pdf_path =, formstack_fields).export(file_name)     @pdf << CombinePDF.load(pdf_path)     application_notes = notes(user_data)      @box.attach_docs_from_submission(user_data).each do |file|       data = @box.client.download_file(file)       is_pdf = (data =~ /\%PDF-\d+\.?\d+/) == 0       package = ""        unless is_pdf         format_image =         package = pdf_document_package(format_image)       end        @pdf << CombinePDF.parse(package)     end      add_notes_page_to_pdf_package(@pdf, application_notes) if application_notes pdf_path     @box.upload_file_to_box(pdf_path, pdf_path)   end    def parse_name(name)     name.match(FORMSTACK_NAME_PATTERN).captures.join(' ')   end    def format_name(name)     name.parameterize.underscore   end    def name_from_submission(submission)     submission["data"].detect { |field_set|       field_set["field"] == name_field }["value"]   end    def name_file(submission)     unparsed_name = name_from_submission(submission)     parsed_name = parse_name(unparsed_name)      format_name(parsed_name)   end    def name_pdf_file(pdf_file_path)     pdf_file_path.gsub(PATH_OF_PARSED_PDF_FILE, '')   end    def add_path_to_file_name(file_name)     "#{PATH_OF_PARSED_PDF_FILE}#{file_name}"   end    def name_field     formstack_fields.find {|f| f["label"] == "Client Name"}.fetch("id") || ""   end    def notes(user_submission)     notes_field = user_submission.find { |field| field['field'] == notes_section_id}     notes_field&.fetch('value')   end    def notes_section_id     notes = "use_the_space_below_to_add_notes_to_this_application"      formstack_fields.find {|field| field["name"] == notes }.fetch("id")   end    def add_notes_page_to_pdf_package(pdf, notes)     @pdf_prawn.text notes     @pdf << CombinePDF.parse(@pdf_prawn.render)   end    def pdf_document_package(string_image)     pdf_blank_pages.image(       string_image,       fit: [         PDF_PAGE_WIDTH,         PDF_PAGE_LENGTH       ],       position: :center     )     pdf_blank_pages.render   end    def pdf_blank_pages 'LETTER', margin: 0)   end end 

Is there something I’m missing? What style violations am I committing? How can I get rid of these dependencies?

Gravity form to Wsdesk ticket with attachment

Scenario: I am using gravity forms for guests to submit a form with attachment. Once the form is submitted I am running an API on

add_action('gform_after_submission_1', 'after_submission', 10, 2);  

The Hook above allows me to make a new Ticket on Wsdesk as Needed but I need to attach the file with it. The API call is working. File submission is not working as wanted. The entry[19] is for file and returns a url

function after_submission($  entry, $  form) {     $  url = "";   // initialise the curl request $  request = curl_init($  url);  $  file_temp = download_url($  entry[19], 5);  // send a file curl_setopt($  request, CURLOPT_POST, true); curl_setopt(     $  request,     CURLOPT_POSTFIELDS,     array(         'action' => 'wsdesk_api_create_ticket', // Request Type         'api_key' => 'XXXXXXXXXXXXXXXXXXXXX', //API Key.         'request_email' => $  entry[2],// email         'request_title' => $  entry[6.1], // address         // 'request_description' => $  entry[12],         'field_ZO15' => $  entry[1], // full name         'field_RJ34' => $  entry[3], //phone number         'field_XH64' => $  entry[10],// type of inspection         'field_YM91' => $  entry[8], // Time inspection         'file[]' => $  file_temp     ) ); print_r("file: $  file_temp");  // output the response     curl_setopt($  request, CURLOPT_RETURNTRANSFER, true);     echo curl_exec($  request);  // close the session     curl_close($  request); $  response = json_decode($  response['body'], true); die(print_r($  response, true)); if ($  response['status'] == 'success') {     die('success'); } //code if success else {     die('failed'); } //code if fails } 

Term for helpful information in a form

I’m writing up a proposal and got stumped on the description for this element:

enter image description here

The informative text (in pink) underneath a field is there to provide a reason for the required data, therefore answering a users uncertainty around why they need to fill in this field.

The information behind the ‘i’ icon plainly says you must be x years old to register so this isn’t duplicate information.

Is there a specific term for this type of element within a form?