0

フォーム フィールドの 1 つを次のようにレンダリングするには、Rails コードが必要です。

contacts[:custom_field][phone_number]

これをテンプレートファイルで機能させるために、あらゆる種類のことを試しました。

:custom_field=> :phone_number

HTMLでこれを取得します:

name="contacts[{:custom_field=>:license_1234, :class=>"text_field width_100_percent"}]"

IDは次のようになります

id="helpdesk_ticket_custom_field_phone_number_50754"

しかし、フォームを送信すると、API に接続できないというエラーが表示されます。

 Freshdesk::ConnectionError in Website::ContactsController#create

 Connection to the server failed. Please check hostname

コンソールでこれを行うと

  contacts.post_tickets(name: "John Doe", email: 'user@exmaple.net', :custom_field=>{:phone_number=>"123-123-1234"})

できます!と投稿しますが、実際のコードでこれを複製することはできません

html

= form_for(:contacts, url: contacts_path) do |f|
  = f.label "Name"
  %br
  = f.text_field :subject, class: "text_field width_100_percent"
  %br
  %br    
  = f.label "Email"
  %br    
  = f.email_field :email, class: "text_field width_100_percent"
  %br
  %br
  = f.label "Phone"
  %br    
  = f.text_field :custom_field=>{:phone_number_50754=>"AMD-123"}
  %br
  %br
  = f.label "Question(s), and/or feedback"
  %br
  = f.text_area :description, class: "text_field width_100_percent"
  %br
  %br
  = f.submit "Submit", class: 'btn btn-warning'
4

0 に答える 0