Tag: 简单forms

Rails4中的嵌套简单表单 – 有很多通过,保存多个记录

通过关系,我有一个标准的has_many。 通过连接表交互,人类拥有许多兽人。 互动只是一个表格和模型; 没有控制器或视图。 使用Rails 4中的simpleform gem,我想从人体页面创建一个表单,以便从所有兽人的池中选择多个兽人。 提交后,我希望它在交互表中创建/更新尽可能多的记录,每个记录都包含人员ID,并且选择了多个orc id。 : AKA列表符号 从一端制作表格(人类) 列出表格中的所有兽人 从该列表中选择多个兽人 使用human_id和orc_id将多个记录保存到交互表中,因为从该列表中选择了兽人。 (human_id在这些记录中将是相同的,因为它从给定的人类表单页面开始) 我将尽可能多地编写整个故事的代码。 请随时要求澄清,并解决任何错误,以实现这一点。 表 humans integer “id” interactions integer “human_id” integer “orc_id” index [“human_id”, “orc_id”] # This is the primary key. no normal id. # Is it better to have a primary id for this join table, or does it […]

使用simple_form和zurb基础创建内联date_select下拉列表

我在我的rails应用程序中使用Simple_Form和Zurb Foundation。 一个或多个视图的表单具有以下date_select 表单字段显示堆叠而不是内联。 我已经检查了所有内容,无法弄清楚如何正确显示这些内容。 我错过了什么? 您可以在event.html.erb视图中看到https://github.com/stanrails/momtomom上的回购。 该部分的代码如下:

如何摆脱包装simple_form中每个输入的div?

这个输入: {:class => “span8”}, :placeholder => “Park Slope, Prospect Heights, Fort Green…” %> 产生这个: 如何在没有div的情况下单独生成input ? 谢谢。

数字字段Simple_form_for

在使用Simple_form_for时,在我的数字字段中,使用Google Chrome时,字段旁边会显示滚动条。 我怎么能阻止他们出现?

Rails 4 simple_form has_many通过复选框不保存

我正在尝试使用simple_form通过复选框实施员工经常扣减表。 我的代码有效,但所选的经常扣减不会保存在我的表格中。 我无法理解为什么。 这是我的模特。 class Employee :employee_recurrents end class Recurrent :employee_recurrents end class EmployeeRecurrent < ActiveRecord::Base belongs_to :employee belongs_to :recurrent end 移民 class CreateEmployeeRecurrents false do |t| t.references :employee t.references :recurrent end add_index :employee_recurrents, [:employee_id, :recurrent_id] add_index :employee_recurrents, [:recurrent_id, :employee_id] end end 形成 调节器 def employee_params params.require(:employee).permit(:first_name, :recurrent_ids) end 这是我编辑的日志 Started PATCH “/employees/1” for 127.0.0.1 […]

Rails 3 + Ajax:如何访问我的本地表单构建器实例

我有一个显示一组输入的表单。 我也有一个按钮,当点击时,我发出一个ajax请求,它应该用一组不同的输入替换现有的输入。 我所有的ajaxy链接东西都很好。 问题是我使用的是form_for ,所以为了显示新的表单输入,我需要表单构建器实例。 查看文件 我希望我的js.erb看起来像这样,但f只在视图中的窗体范围内定义。 $(‘#info’).html(“”); 我该如何工作以便能够以某种方式进入该部分?

带有自定义包装器的simple_form自定义输入

我正在尝试在我的应用中为货币进行自定义输入。 我有那些bootstrap包装器等(我认为它带有simple_form或带有bootstrap gem …),所以,我可以做类似的事情: :append do %> 它的工作方式与预期一致。 问题是:我在很多地方需要同样的东西,而且我不想复制/粘贴它。 所以,我决定创建一个自定义输入。 到现在为止,我得到了以下代码: class CurrencyInput :append do |b| # content_tag(:span, “$”, class: “add-on”) b.text_field(attribute_name, input_html_options) end end end 但是我遇到了一些错误。 看起来b没有像预期的那样出现,所以,它只是不起作用。 真的有可能这样做吗? 我找不到任何例子,也不能让它自己工作。 提前致谢。

在Devise中自定义路由到新用户注册页面Simple_Form_For将新表单发布到设计注册控制器

一个想法 – 我应该制作一个inheritance注册控制器的新控制器吗? 然后做另一个 devise_for :users, :controllers => {:registration => “newcontroller”} 将trial_signup.html.erb更改为new.html.erb 并在app / views / devise / registrations2 / new.html.erb中创建一个新文件夹 最新更新 app / views / devise / trial_signup.html.erb Trial Sign up resource_name, :url => sales_path(resource_name)) do |f| %> true, :input_html => { :class => “form-control” } %> { :class => “form-control” } %> true, […]

simple_form_for rails单选按钮内联

我试图让我的按钮显示内联,并具有默认值,因为它不能为空。 我正在使用plataformatex / simple_form和bootstrap。 = f.collection_radio_buttons :is_private, [[true, ‘Private’], [false, ‘Public’]], :first, :last, style: “display:inline”, default: true 它呈现这个: Private Public 很明显, style:工作不正常,但我不确定会起作用。 继另一个建议后,我补充道 .radio_buttons { display:inline; } = f.collection_radio_buttons :is_private, [[true, ‘Private’], [false, ‘Public’]], :first, :last, :item_wrapper_class => ‘radio_buttons’, :default => true 得到了: Private Public 只是另一个注意,默认值仍然无法正常工作。

Rails simple_form属性需要标记(*)

我在我的应用程序中使用简单表单,我想删除*以指示我的所有表单(现有和尚未创建的表格)上都需要属性。 我试过在simple_form.rb设置: # Whether attributes are required by default (or not). Default is true. config.required_by_default = false 我试图修改simple_form.en.yml : required: text: ‘required’ mark: ” # <—— tried setting this to blank. 我知道我可以在每个字段上设置:required => false ,但我想清理视图并设置一次。