以简单的形式更改 id [英] Change id in simple form

查看:41
本文介绍了以简单的形式更改 id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改默认 id 或 class,从而生成简单的表单:

= simple_form_for(@account, url: account_url, validate: true, wrapper: :inline, html: { method: :put }) do |f|

html:

<form accept-charset="UTF-8" action="http://mikhail.smackaho.st:3000/account" class="edit_account" data-validate="true" id="edit_account_4f15c0a487f4463d8d000004" method="post" novalidate="novalidate"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"><input name="_method" type="hidden" value="put"><input name="authenticity_token" type="hidden" value="BZFZUGlbZU2ILGR/fdMW5QWNdDgWNPvGpZR13LFwhmw="></div><div class="inputs"><div class="clearfix string required"><label class="string required" for="account_company_name">公司名称<abbr title="required">*</abbr></label><div class="input"><input autofocus="autofocus" class="string required" data-validate="true" id="account_company_name" name="account[company_name]" size="50"type="text" value="mikhail"></div></div><div class="actions"><input class="btn primary" name="commit" type="submit" value="Update"><button class="btn" name="button" type="reset">取消</button>

</表单>

帐户 - 单个资源.我想要没有 id_hash 的像 edit_account 这样的 id

解决方案

html 选项中指定 id:

= simple_form_for @account, url: account_url, wrapper: :inline, html: { method: :put, id: :edit_account } do |f|

How change default id or class, which produce simple form:

= simple_form_for(@account, url: account_url, validate: true, wrapper: :inline, html: { method: :put }) do |f|

html:

<form accept-charset="UTF-8" action="http://mikhail.smackaho.st:3000/account" class="edit_account" data-validate="true" id="edit_account_4f15c0a487f4463d8d000004" method="post" novalidate="novalidate"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"><input name="_method" type="hidden" value="put"><input name="authenticity_token" type="hidden" value="BZFZUGlbZU2ILGR/fdMW5QWNdDgWNPvGpZR13LFwhmw="></div>

      <div class="inputs">
        <div class="clearfix string required"><label class="string required  " for="account_company_name">Company name <abbr title="required">*</abbr></label><div class="input"><input autofocus="autofocus" class="string required " data-validate="true" id="account_company_name" name="account[company_name]" size="50" type="text" value="mikhail"></div></div>
        <div class="actions">
        <input class="btn primary" name="commit" type="submit" value="Update">
        <button class="btn" name="button" type="reset">Cancel</button>
      </div>
    </form>

Account - single resource. I want to have id like edit_account without id_hash

解决方案

Specify the id within the html option:

= simple_form_for @account, url: account_url, wrapper: :inline, html: { method: :put, id: :edit_account } do |f|

这篇关于以简单的形式更改 id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆