问题标签 [form-helpers]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
ruby-on-rails - Rails 3:向用户帖子添加是/否“推荐”选项
我是 Rails 新手,我正在开发一个简单的应用程序,用户可以在其中创建带有内容的帖子,呵呵。但是由于我是真正的新人,所以我有些困惑。当用户创建帖子时,我希望他们有一个“推荐选项”是/否,默认为否。因此,如果用户想要推荐一个帖子,他只需在提交表单之前选择是单选按钮。我已经让用户和帖子模型工作以创建带有标题和正文的帖子。模型关系是 users has_many posts,posts belongs_to user。
我想让它保持非常简单,只需使用默认为 no 的 no/yes 单选按钮向 post 模型添加一个“推荐”属性。我对 rails 表单助手以及如何在我的迁移后添加是/否属性感到困惑。那么我将如何选择特定@user 推荐的一系列帖子?非常感谢!
html - CakePHP - FormHelper 不输出表单标签
我有以下表格声明:
它没有输出<form></form>
标签,我已经在整个应用程序中以这种方式声明了我的表单,添加$this->Form->end()
也不起作用,有什么线索吗?
编辑:明确声明<form></form>
标签也不输出它们
编辑2:我注意到了一些非常奇怪的事情。我的页面上有 4 个有问题的表单,如果我删除了有问题的元素的渲染,我的另一个表单将不会呈现,紧随其后的那个。
php - 与 CakePHP 的简单关联
我最近开始研究 CakePHP——到目前为止我很喜欢。但是,我需要问一个相当简单的问题:
这是关于模型关联的。我有 2 个模型用户和组。一个用户可以有多个组,一个组只能有一个用户。所以我做了这样的:
然后在添加组页面上,我希望可以从下拉列表中选择用户。我的组添加视图如下:
user_id 会自动转换为下拉列表 - 但是没有任何选项。我需要做什么?我假设我需要放置一个应该从用户表中获取“名称”的地方。
ruby-on-rails-3 - form_helpers Rails 3 - 在循环中包含对象
旅游has_many :photos
,照片belongs_to :tour
。
游览的字段是:title, :description
。
照片的字段是:alt, :image (path), :tour_id
旅游accepts_nested_attributes_for :photos
旅游attr_accessible :photo_attributes
--
在旅游表格中,我想在保存后返回表格中的相应旅游照片,以便用户可以看到他们上传的照片并添加他们的 Alt 标签
这是表单的样子,但我不知道如何将任何保存的图像带回表单......
我很困惑,因为很明显 form_helper 可以将表单的已保存元素带回表单字段中。但我不知道如何在图像标签中使用其中一个已保存的元素...
ruby-on-rails-3.1 - 更改 text_field_tag rails 3.1 的大小
我在用作搜索框的 text_field_tag 中使用以下选项。我想更改 text_field 标签的宽度和高度。
除了尺寸之外,我能够获得所有想要的效果。据我所知语法是正确的。我也在使用 bluprint.css。只是为了确保我注释掉了蓝图 css textarea 默认选项。
可能是什么问题?
ruby-on-rails-3 - Rails 3 - 使用集合选择中的选定值创建“link_to”
大家好。
我的 rails 3 应用程序中有一个表单,其中一个字段是这样的“集合选择”
这个想法是能够使用“集合选择”中的选定值添加“link_to”,即:
但是,我不知道如何获得选定的值。有没有一种方法可以做到这一点?
希望你能帮助我,谢谢
ruby-on-rails - 在 ime_zone_select 上指定 CSS 类
有没有办法在 time_zone 选择助手上指定 CSS 类。我有这样的代码 -
f.time_zone_select :time_zone, ActiveSupport::TimeZone.us_zones
ruby-on-rails - 在 time_zone_select 上应用 CSS 类
是否可以为 Rails 3 中的 time_zone_select FormHelper 提供 CSS 类。我目前有类似的东西
尝试过类似的选项 -
f.time_zone_select :time_zone, nil, :class => 'classname'
但这不起作用
clojure - Clojure: Hiccup form-handler
I am implementing a simple drop-down using hiccup:
What I need is to issue a post request (as I think this the only way to do it, but I am open to suggestions) when the drop-down is selected on a specific table (so that "get-cols-nms" gets called with the selected table). In this way, when a table of the database is selected in the drop-down, the table columns will be automatically showed.
So, ultimately, the main point is for me to understand better this function:
I think that to do what I want I need the tag to have an "onchange" attribute that calls a javascript function. But I don't know: 1) if I can do this using the hiccup form-helper drop-down; 2) how can I issue (if this is the only solution, maybe there is an hiccup way?) a post request with javascript.
==EDIT==
Following the answer to this question, I rewrote the code above.It should be pretty straightforward. As I think there are not so many examples of hiccup out there, I will post my code here for reference.
Please, bear in mind that there is still a problem with this code: the drop-down won't stay on the selected item, but it will return at the default. This is because it submits "onchange". I still could not find a solution for that, maybe somebody could help...
ruby-on-rails-3 - collection_select 方法在 Rails 3.1.1 中给出错误
我有一个名为 Category 和其他 Model Product 的模型。他们有 has_many 和 belongs_to 关系。但在我看来代码
在给我
任何线索有什么问题吗?