formtastic

Error while updating a record using Formtastic in HAML templates

I am using formatastic in a HAML form. - semantic_form_for @company do |f| - f.inputs do = f.input :description = f.input :type = f.input :industry = f.input :hq = f.input :products = f.input :subsidiaries = f.input :employees = f.input :revenue = f.input :net_income = f.buttons When ...

Using fields from an association (has_one) model with formtastic in rails

I searched and tried a lot, but I can't accomplish it as I want.. so here's my problem. My models are: class User < ActiveRecord::Base has_one :profile accepts_nested_attributes_for :profile end class Profile < ActiveRecord::Base attr_accessible :user_id, :form, :title, :name, :surname, :street, :housenumber, :zipcode, :place, :...

How do I add custom buttons to Formtastic?

I'm using the Formtastic Rails gem in my app and its been great, but I would really like to add a second button, other than the bundled "commit" button that redirects back. I can't seem to find any information on how to add a custom button. Any information would be greatly appreciated! ...

validates_associated in production

Hi all. Imagine a simple model. class Service belongs_to :user validates_associated :user accepts_nested_attributes_for :user end Nothing special right? The validations on the associated User model trigger correctly in development mode. But don't do anything in production. I've added a validates_on_presence :user just like the d...

saving nested attributes

I have a form that has a nested form like this: <%- for subscription in @task.subscriptions -%> <%- semantic_fields_for "task[subscription_attributes][]", subscription do |subscription_form|%> <%- subscription_form.inputs do -%> <%= subscription_form.input :workhours, :label => subscription.user.full_name%> ...

How do I make a grouped select box grouped by a column for a given model in Formtastic for Rails?

In my Rails project I'm using Formtastic to manage my forms. I have a model, Tags, with a column, "group". The group column is just a simple hardcoded way to organize my tags. I will post my Tag model class so you can see how it's organized class Tag < ActiveRecord::Base class Group BRAND = 1 SEASON = 2 OCCASION = ...

No-Model Formtastic Form

I am looking to reproduce the following with Formtastic: <% form_tag '/search', :method => 'get' do %> <%= text_field_tag :q, params[:q] %> <% end %> So far I have: <% semantic_form_for :search, :html => { :method => :get } do |form| %> <% form.inputs do %> <%= form.input :q %> <% end %> <% end %> However, this requires a...

Creating a second form page for a has_many relationship

I have an Organization model that has_many users through affiliations. And, in the form of the organization ( the standard edit ) I use semanting_form_for and semantic_fields_for to display the organization fields and affiliations fields. But I wish to create a separete form just to handle the affiliations of a specific organization. I...

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 to work with Haml Formtastic? To add some context here's a simplified version of the p...

HTML - Correct way of coding a checkbox with a Label.

I've been using formtastic in order to generate HTML forms on rails applications. My question, however, is really HTML-related. Today I found a strange behaviour on the way formtastic generates checkboxes (fields of type :boolean on formtastic lingo). The rest of the fields (non-checkboxes) are generated this way: <li> <label for="m...

Formtastic, own :as input type

How I can add my own field types to formtastic ? For exemple, I need to have a custom datetime input, and I want something like this: <%= f.input :start_date , :as => :my_date %> This obviously doesn't work because formtastic doesn't know the :my_date (only :boolean, :string, :datetime and so on...) But how can I add additional inpu...

How to combine formtastic with Ajax form submission?

I would like to use formtastic instead of standard Rails helpers for my forms, however I currently submit them using Ajax (with remote_form_for). I suppose I could use the jQuery form plugin to Ajax-ify formtastic forms, but would it be the best approach? ...

How do I load Formtastic to test it?

I am using Rails 2.0.2 and following Github installation instructions: 1. add as gem source ie "gem sources -a http://gemcutter.org/".....ok 2. install gem ie "gem install formtastic"....gives error, could not find formtastic locally or in a repository I am learning Ruby on Rails and have no knowledge of gems ...

Routing is using ID has action and action has ID after submitting a form

I have a model User that has_one user_profile and a User_Profile belongs_to user in the User controller I have: def personal @user = User.find_by_id(params[:id]) @user_profile = @user.user_profile @user_profile ||= @user.build_user_profile end def update_personal @user = User.find_by_id(params[:id]) if @user....

has_many :through formtastic multi-select field

I'm trying to set up a many to many relationship using the has_many :through method and then use a multi-select field to setup the relationships. I'm following this tutorial: http://asciicasts.com/episodes/185-formtastic-part-2 However for some reason the form displays a strange hex number and it changes each page refresh, I'm not exac...

formtastic weird month name display

Hi, i'm using formtastic, all is ok, but strange thing - on = form.input :birthdate, :as => :date it renders to something like <li><label for="profile_birthdate_2i">Month</label><select id="profile_birthdate_2i" name="profile[birthdate(2i)]"> <option value="1">114</option> <option value="2">97</option> <option value="3"...

formtastic - :string field value as Array and not found-s

Hi, is there any possibility to send from formtastic form value of :string field like - semantic_form_for :project do |form| - form.inputs do = form.input :task_ids, :as => :string as Array? Currently value of this field is sending as String and i'd like to no parse this string in controller. Also, could you give me idea - if task...

Rails: Formtastic: Select-Boxes without primary blank field

Hi, 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. Thanks! Yours, Joern. ...

Rails — Formtastic, how to set text for options in select?

f.input :some_model_values, :as => :select Using Formtastic, I need to set a text for options on my select input, but not populated from :some_model_values. The second: how could be collection of :some_model_values pre-modefied? Because i don want to show some options according to user role. Thanks! ...

Formtastic, pre-modification of symbol

I have input/select on Formtastic form f.input :some_model_values, :as => :select The problem is i need to pre define :some_model_values. Because some users roles have to see all list, and some others not. How it can be done? Thanks. ...