search for: formbuild

Displaying 20 results from an estimated 36 matches for "formbuild".

Did you mean: formbuilder
2005 Dec 27
2
Rewriting FormBuilder
Hi, I want to extend formbuilder to make it output a lable (I know about labeled_form_helper made by technoweenie), my own formating, and a couple of extra tags inside the form attribute. I was easily able to extend form_remote_to. But when I continue to adjust the way elements are handled I don''t know how to contin...
2006 Apr 23
3
custom form builder
In the API docs I found this: "You can also build forms using a customized FormBuilder class. Subclass FormBuilder and override or define some more helpers, then use your custom builder " I couldn''t find any further documentation on this. Where can I read more about this formbuilder class? For starters, where would I define a subclass of this class? TIA, Jeroen...
2006 Jun 05
3
ActiveRecord validations and FormBuilder
Hi, I''m writing my own FormBuilder and I wanted to put an asterisk or something next to any required fields. The Builder has access to the AR object, is there any method I can call on the AR object that will tell me whether or not a particular field is required? Failing that, can I access the complete list of validations...
2007 Aug 20
0
FormBuilder in rjs
...id => X } end RJS: /city/search.rjs page.replace_html ''state_div'', :partial => ''list'', :object => @cities, :locals => { :f => ???? } My problem is that when rendering my partial ''city/list'' from new.rhtml, I have access to my FormBuilder f and therefore can DRY up my params hash key ''customer'' for all form input elements I use in my partial, which is great. However, when I render my partial from an rjs, I no longer have access to the FormBuilder f. I don''t want to hard-code the controller#params key ...
2012 Sep 08
4
dash symbol
In the example below, what is the dash doing between the class attribute and array: (field_helpers - [:label, :check_box, :radio_button, :fields_for, :hidden_field, :file_field]).each do |selector| -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to
2007 Oct 20
14
Problems with form_for and partials
...iews/common/form <% form_for ... do |f| -%> <%= render :partial => "params[:controller]/form", :object => f %> <p>Submit buttons...</p> <% end -%> I''m having problems with stub_render because of the :object => f. I have tried creating a FormBuilder instance to use there as the :object but it doesn''t seem to want to match the actual instance there, which has a large amount of additional information due to the template being run at that point. Then in the partial: # app/views/users/_form <p> <label>Name</label>...
2006 Apr 06
0
FormBuilder-friendly labels?
I''m trying to find a good way to emit <label> tags inside a form_for() block, without needing to repeat the name of the instance variable constantly. Is there a better way to do this than the snippet below, or do I need to do a little extension to the FormBuilder itself? <% form_for :long_example_name, @long_example_name, :url => { :action => :new } do |f| %> <%= label_tag "long_example_name[some_attribute]", "Some Attribute:" %> <%= f.text_field :some_attribute %> <%= label_t...
2008 Dec 02
1
form_for with partial using do |@f|
Is it possible to pass this FormBuilder object to a controller and then back to a partial? I have a form rendering a partial that i would like to update with a call to my controller based on user selectable parameters, but when the AJAX comes back, i get this error message because i cannot pass a form builder object between the contr...
2006 Dec 05
1
Using render inside a FormBuilder (EdgeRails)
I''m using the latest trunk of 1.2-ish, and I''m wondering how to do what I want to do. I am using a form_for :builder I wrote, simply called TableFormBuilder after the rails cookbook, and want to be able to present help icons automatically. I want these icons to appear next to form fields I am rendering. For example, I have this method in helpers/table_form_builder.rb: # This enables you to use select groups like text fields def select_group(obj...
2007 Apr 09
4
How do i switch off error wrapping for a specific field?
Hi, i have some issues with the default rails error wrapping. It wraps errors in a div with class ''fieldsWithError'', which is not good practice in my eyes. Adding a class ''error'' to the field would be much nicer. My solution to the problem: build your own FormBuilder. Funny enough, i found no (nice) possibility to switch error wrapping off while using the FormHelper methods. As error_wrapping is a method in InstanceTag (and not of FormHelper), it is pretty hard to have a FormBuilder change its behaviour. One possibility is to define def initialize(object_na...
2007 Sep 30
2
Outputing to the browser, how?
Hello, I''m writting some helper methods to write forms, so I have this working code: class TableFormBuilder < ActionView::Helpers::FormBuilder ["file_field", "password_field", "text_field"].each do |name| define_method(name) do |label, *args| @template.content_tag(:tr, @template.content_tag(:td, @template.content_tag(:label, label.to_s.huma...
2007 Aug 06
2
Specifying custom rails FormBuilders
I want to write a spec for a custom form builder, but I''m not really sure where it should live or how to include the right rspec_on_rails contexts. Ideally, I should be able to write a spec like: describe LabelledBuilder do it "should let me create a text field" do object = mock(object) object.stub!(:attribute).and_return("Test String") render
2007 Sep 25
21
form_for and partials
I love form_for, but I really hate <% form_for :person, @person, :url => {...} do |f| %> ... <%= render :partial => ''form'', :locals => {''f'' => f} ... <% end %> I''ve been thinking of instead allowing <% form_for :person, @person, :url => {...} do |f| %> ... <%= f.partial ''form''
2006 Jul 11
0
Arbitrary elements in form_for?
I would like to use form_for in my project so that I can easily change the style of many forms at once. However, it seems to me like FormBuilders only support certain kinds of form elements(!). Surely there must be a way to add arbitrary labels/form elements to a form. Let''s say I had a form that looks like: ID: (plain-text label) Name: (text field) Birthdate: (date chooser) Picture: (picture) Foo: (custom widget) How can I us...
2010 May 28
8
form helpers don't seem to work with RJS files...
...ithin a partial in the RJS file, I get the following error. My goal is simply to load a partial into a div. The fields in this partial require fields_for though. And that’s where the problem lies. ActionView::TemplateError (undefined method `fields_for'' for "#<ActionView::Helpers::FormBuilder:0x944ea28>":String) on line #3 of app/views/trials/observe.rjs: 1: page.alert(''before'') 2: test_func = pluralize(6, ''cat'') 3: @form.fields_for :org_detail do |w| 4: page[''section_two''].replace_html :partial => "mypar...
2008 Dec 07
0
boolean button helper
...in some situations and better convey to the user that they are making a mandatory choice. But doing this with radio buttons typically takes 5 lines of html: 3 labels and 2 radio buttons. Here''s a simple boolean button helper that you can put in your custom form builder. class YourCustomFormBuilder < ActionView::Helpers::FormBuilder ... def boolean_buttons_for(method, label_true = "true", label_false = "false" ) @template.content_tag("div", @template.label(@object_name, method, method.to_s.humanize, :class => ''align'' ) +...
2010 Mar 20
4
Displaying an image in a Rails form_for
...wnArrow.jpg" %> <br> <%= select_tag "test", options_for_select(@current_vendors.collect { |v| v.nickname }), {:multiple => true} %> </p> But Rails gushes the unforgiving response: undefined method `image'' for #<ActionView::Helpers::FormBuilder: 0x48194e0> I couldn''t find anything helpful in: -- http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html -- http://api.rubyonrails.org/http://api.rubyonrails.org/ -- Google Any ideas? Thanks in Advance, Richard -- You received this message because you are subscri...
2009 Feb 05
1
[rspec] [rails] Specing a form builder
...;'m trying to set up and run a new form builder under rails, which lives under the helpers directory, but isn''t really a helper. (Not a module, so doesn''t mix in well) Short of dropping down into a view spec, how do I set up to actually spec the form builder? describe RandomFormBuilder do attr_reader :builder before do @object = mock_model(Foo) @builder = RandomFormBuilder.new(:foo, @object, #template#, {}, nil) end describe "#text_field" do it "should have a label" do @builder.text_field(:foo).should have_tag("label",...
2010 Jun 23
3
Custom default form builder in Rails 3
Hello everyone, I am trying to set a default custom form builder. I have defined my form builder class in "lib/mymodule/mybuilder.rb" as: module Mymodule class Mybuilder < ActionView::Helpers::FormBuilder ...... end end Then I am trying to use this custom class in application.rb as config.action_view.default_form_builder = Mymodule::Mybuilder. But I get "Uninitialized constant error." Does this mean that my module stored in "lib" directory is not loaded automatically?...
2011 Sep 13
3
Accessing Rails helper method with_output_buffer
Hi all, I cannot figure out how to correctly use the with_output_buffer helper method (located in ActionView::Helpers::CaptureHelper) inside a custom FormBuilder. Below follows a simplified example. I''m trying to achieve the following behavior in an ERB as suggested in the form_for helper docs in the Rails source: ========== <%= form_for @object, :builder => MyFormBuilder do |my_form| %> <%= my_form.my_dummy_div_wrapper do %>...