简体   繁体   English

如何在Rails中设置表单的名称?

[英]How do I set the name of a form in Rails?

I tried 我试过了

<%= form_tag ("/ombcauth", name:"ombc_form") do %>

But it gave me a syntax error: 但它给了我一个语法错误:

syntax error, unexpected ',', expecting ')' ...append= form_tag ("/ombcauth", name:"ombc_form") do @output... 语法错误,意外',',期待')'... append = form_tag(“/ ombcauth”,名称:“ombc_form”)做@output ...

I also tried 我也试过了

<%= form_tag ({action:"/ombcauth"}, {name:"ombc_form"}) do %>

But that also gave me a syntax error 但这也给了我一个语法错误

syntax error, unexpected ',', expecting ')' ...form_tag ({action:"/ombcauth"}, {name:"ombc_form"}) do @outp... 语法错误,意外',',期待')'... form_tag({action:“/ ombcauth”},{name:“ombc_form”})做@outp ...

I need to reference the form in a link to submit. 我需要在提交的链接中引用表单。

<%= link_to "OMBC Auth", "#", {onClick: "document.ombc_form.submit(); return false;"} %> 

rails --version rails --version
Rails 3.2.11 Rails 3.2.11

What you did is correct. 你做的是对的。 The problem is in the white space between form_tag and ( : 问题出在form_tag(

<%= form_tag("/ombcauth", name:"ombc_form") do %>

Or without parenthesis: 或者没有括号:

<%= form_tag "/ombcauth", name:"ombc_form" do %>

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在此Rails 2选择表单中设置所选选项? - How do I set a selected option in this Rails 2 selection form? 如何在Rails中为联系表单设置邮件传递? - How do I set up mail delivery for a contact form in Rails? 为什么Rails表单助手会更改我提供的ID /名称,如何使其停止? - Why do rails form helpers change the id/name I provide, and how can I make it stop? 如何获取Rails表单构建器将为特定字段生成的HTML“名称”属性? - How do I get the HTML 'name' attribute a rails form builder will generate for a certain field? 如何在Rails中搜索类别名称? - How do i search category name in Rails? Ruby on Rails:如何将变量设置为常量,常量名称的一部分可以更改? - Ruby on Rails: How do I set a variable to a constant, where part of the name of the constant can change? 如何设置Rails表单以提交给create方法? - How do I set up my Rails form to submit to a create method? Rails 3,多对多形式使用accepts_nested_attributes_for,如何正确设置? - Rails 3, many-to-many form using accepts_nested_attributes_for, how do I set up correctly? Rails 5.1 - 如何为 Bootstrap 4 自定义表单验证设置“novalidate”? - Rails 5.1 - How Do I Set “novalidate” for Bootstrap 4 Custom Form Validation? 如何设置Simple_Form文本区域的最小长度? Ruby on Rails - How do I set minimum length of my Simple_Form textarea? Ruby on Rails
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM