Questions tagged [formtastic]

Formtastic is a Rails form builder plugin with semantically rich and accessible markup.

Formtastic is, "a Rails form builder plugin with semantically rich and accessible markup", according to the Formtastic GitHub repository.

Formtastic is maintained by Justin French and José Valim and has received contributions from many community members.

There are two Railscasts episodes which focus on Formtastic:

696 questions
76
votes
2 answers

ActiveAdmin with has_many problem; undefined method 'new_record?'

I'm trying to customise a ActiveAdmin form for a Recipe model that has a has_many relationship with Step. class Recipe < ActiveRecord::Base has_many :steps end class Step < ActiveRecord::Base acts_as_list :scope => :recipe belongs_to…
nickpellant
  • 1,046
  • 1
  • 7
  • 9
35
votes
2 answers

Get a value of object field inside fields_for loop

In the following scenario, I need to check the value of the object property in the fields_for loop. <%= f.semantic_fields_for :review_details do |rd| %> <%= rd.input :review_criteria_id, :as=>:hidden %> <% end %> As in the loop,…
33
votes
2 answers

formtastic - how to prepopulate a string input with a value

I'm building an app, where users can give comments by just leaving their email to the comment. I want them to be able to register directly from there, by a link with their email adress as a param (like: <%= link_to register_path(:email =>…
ernd enson
  • 1,764
  • 1
  • 14
  • 29
32
votes
6 answers

how to change class of a label for checkboxes in simple_form

using simple_form we can change class of a label using: label_html => {:class => "myclass"} but how do we do the same when dealing with checkboxes? simple_form assigns the default class of collection_check_boxes Is there a way to change this…
Omnipresent
  • 29,434
  • 47
  • 142
  • 186
32
votes
6 answers

How to display only the value in edit page in Active Admin

I have a edit form in Active Admin. I need some field as read only. My current edit page is like I need the page look like this How can this be done. My code for the edit form page is like form :html => { :enctype => "multipart/form-data" }…
Amal Kumar S
  • 15,555
  • 19
  • 56
  • 88
27
votes
3 answers

rails ActiveAdmin nested form has_one accepts_attributes_for formtastic issue

I am using ActiveAdmin and Rails 3.1 -- having problem understanding whether the following is a bug, or if there is some way to do it correctly that I am not understanding. I am trying to use a nested model with a has one relationship, so that I can…
27
votes
2 answers

Rails: Formtastic: Select-Boxes without primary blank field

It's about Rails and Formtastic. How can I add a select box with formtastic without an initial/primary blank field? So that the initially selected item is the first item with content.
Joern Akkermann
  • 3,542
  • 8
  • 33
  • 41
24
votes
4 answers

How to add and remove nested model fields dynamically using Haml and Formtastic

We've all seen the brilliant complex forms railscast where Ryan Bates explains how to dynamically add or remove nested objects within the parent object form using Javascript. Has anyone got any ideas about how these methods need to be modified so as…
Jack Kinsella
  • 4,491
  • 3
  • 38
  • 56
22
votes
16 answers

Customizing field_with_errors

Is there a way to tell Rails to not create div.field_with_errors around both label and actually field, but to create div.error around them both? E.g. snippet from my view with the form (written in HAML) = form_for @user do |f| %div.clearfix =…
21
votes
5 answers

How to filter IS NULL in ActiveAdmin?

I've a table with an integer column called "map_id", I want to add an activeadmin filter to filter if this column IS NULL or IS NOT NULL. How could this be implemented ? I tried the following filter filter :map_id, :label => 'Assigned', :as =>…
20
votes
4 answers

How to pre-check checkboxes in formtastic

I have a form I'm trying to set up ... Users can have many posts, and each post can have many people watching it. The Watch model is set up polymorphically as 'watchable' so it can apply to different types of models. It has a user_id, watchable_id,…
concept47
  • 30,257
  • 12
  • 52
  • 74
18
votes
3 answers

Rails Formtastic: adding "data-" field to option tag

I have: form.input :duration, as: select, collection: {} I need: Rails does not support HTML5 data attributes for the option tag. Formtastic suggests to create a helper method for this. Formtastic readme…
krn
  • 6,715
  • 14
  • 59
  • 82
18
votes
1 answer

Is there any way to create a form with formtastic without a model?

I would like to use formtastic to create form but I don't have a model associated with that (login form with username, password and openid URL). Of course I could create a model to do that but that model was just a hack without any useful code in…
KARASZI István
  • 30,900
  • 8
  • 101
  • 128
16
votes
4 answers

Insert a non-input row into a Formtasic form

I am using Formtastic 2.1.1 in Rails 3.2 (with Active Admin) and I want to insert a row into my form that does not have an input field present. Is this possible and what is the syntax in the Formtastic DSL to achieve this? Here's an example: form do…
Randy Burgess
  • 4,835
  • 6
  • 41
  • 59
14
votes
4 answers

Image file input with Formtastic and ActiveAdmin

I started using formstatic but I need to make a file field with an image preview. I mean, when I edit an object, I want to see the image already linked. How can I do that?
Sebastien
  • 6,640
  • 14
  • 57
  • 105
1
2 3
46 47