Coder Social home page Coder Social logo

Comments (10)

dwightwatson avatar dwightwatson commented on July 24, 2024

I too would like to see this addition.

from bootstrap_form.

sovetnik avatar sovetnik commented on July 24, 2024

At first, thanks for great gem!

At second, one question:
If bootstrap_form_tag allows me to use it instead of?

 <%= form_tag produce_recipe_path, method: :post, class: "form-inline"  do %>
    <%= text_field_tag :count %>
    <%= submit_tag "Produce", class: "btn btn-success btn-sm" %>
<% end %>

Then i wait for bootstrap_form_tag too. Or you know another method for custom actions in bootstrap?

from bootstrap_form.

carloslopes avatar carloslopes commented on July 24, 2024

@oblaka yes, bootstrap_form_tag would allow you to do that.

This is really a useful feature, but there are some things that should be discussed before we do any work on it.

Today, we know which type of form the user want checking the options passed to bootstrap_form_for method (example: bootstrap_form_for @user, style: :horizontal)

With a bootstrap_form_tag we wouldn't have a relation between the form and the elements, so, how could we know which type of control should be rendered? horizontal or inline?

from bootstrap_form.

sovetnik avatar sovetnik commented on July 24, 2024

Maybe it's possible to make it similar bootstrap_form_for way?
For example,

<%= bootstrap_form_tag( controller: 'recipe', action: 'produce', method: :post, style: :inline) do |f| %>
<%= f.text_field :count %>
<%= f.submit "Produce", class: :success %>
<% end %>

or add 'f.form_group' around elements (if elements should be rendered in non-default control type)?

from bootstrap_form.

baldwindavid avatar baldwindavid commented on July 24, 2024

One method for getting some of this functionality is in pull request #70. I'm not sure that is the direction to take, but it might help in the discussion.

from bootstrap_form.

sovetnik avatar sovetnik commented on July 24, 2024

Thanks, man! How about add validations functionality?
Anonymous models haven't owns, so next step is define place for it. What do you think?

from bootstrap_form.

baldwindavid avatar baldwindavid commented on July 24, 2024

I added the PR but, in practice, pretty much the only time I would ever use it is if I was submitting to a site outside of my application with very different field conventions. In most other cases, whether the form is AR-backed or not, I am going to use a form object. Rails 4 makes it pretty trivial to create form objects that you can use with form_for rather than form_tag.

The example above could be used with form_for with just this...

class ProduceRecipeForm
  include ActiveModel::Model
  attr_accessor :count
end
<%= bootstrap_form_for :produce_recipe_form, url: produce_recipe_path do |f| %>
  <%= f.text_field :count %>
  <%= f.primary "Produce"
<% end %>

Validations can be added to the ProduceRecipeForm in the same manner as they are in models inheriting from ActiveRecord...

validates :count, presence: true

from bootstrap_form.

sovetnik avatar sovetnik commented on July 24, 2024

I create form as you suggested, it works, but validations still not working. Could you see on commit, maybe i do it wrong? sovetnik/cooker@c59e2ec

from bootstrap_form.

potenza avatar potenza commented on July 24, 2024

closed with #70

from bootstrap_form.

baldwindavid avatar baldwindavid commented on July 24, 2024

@oblaka - This article will probably help you in getting your form working... http://robots.thoughtbot.com/activemodel-form-objects

Basically, you'll need to kick off the validation in your create action.

from bootstrap_form.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.