On this edit page screen I've set up a "Current Password" field required to edit the user information (to change my name for example) but for some reason that particular current password field is not showing up while all the other input fields do.
I can't figure out why its not showing up?
Thank you!
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { :method => :put, class: 'form-horizontal'}) do |f| %>
<%= f.error_notification %>
<%= f.input :name, :label => "Nombre" %>
<%= f.input :email, :label => "Correo Electronico" %>
<%= f.input :password, :label => "Nueva Contraseña", autocomplete: "off" %>
**<%= f.input :password_confirmation, :label => 'Confirmar Contraseña', autocomplete: "off" %>**
<% f.input :current_password, :label => "Contraseña Actual" %>
</br>
<div class= "form-actions">
<%= f.submit "Actualizar Datos", class: "btn btn-primary"%>
</div>
<% end %>
You forgot to add the = in the ERB tab. It won't echo to the page without that. It should look like this:
<%= f.input :current_password, :label => "Contraseña Actual" %>
Keep in mind, statements whose values you do not want to show on the page should omit the equals (=) sign. Examples of those statements would be things like <% if ... %>, <% #some_var.each do .... %> etc.
Values you do wish to appear on the page, such as your input line, should have the equals sign.
Related
I'm trying to add Mapbox autofill to my address bar on rails, for mapbox autofill to work I need to have autocomplete="street-address in an input field.
I'm using simple_form_form and I can't figure out how to add autocomplete attribute. Here is my form:
<%= simple_form_for #lock do |f| %>
<div class="form_wrapper">
<div class="form_div">
<%= f.input :name %>
<%= f.input :description %>
<mapbox-address-autofill>
<%= f.input :address, :autocomplete => "street-address" %>
</mapbox-address-autofill>
<%= f.input :photo, as: :file, label: "Link to picture" %>
<%= f.input :special_content %>
<%= f.button :submit, :class => "btn btn-primary" %>
<% end %>
any ideas on how to make the autocomplete attribute work?
Use input_html and pass the additional options like class etc.
<%= f.input :address, input_html: { :autocomplete => "street-address"} %>
I have a drop down selector in a form and even after saving an object, when I go to my edit page, the drop down reverts to the first item. If submit is clicked, the value changes to the first item in the list.
In this case the drop down contains a list of states. Every time I go to the edit page, Alabama is selected and if I don't manually change the value back to what it initially was, the state becomes Alabama.
<%= simple_form_for #event, url: coin_event_path(#coin.id) do |f| %>
<%= f.input :content, :label => "Event Description", class: 'form-control' %>
<%= f.input :link, :label => "Link to Event", class: 'form-control' %>
<%= f.input :date, order: [:month, :day, :year], class: 'form-control' %>
<%= f.input :time, as: :time, html5: true, class: 'form-control' %>
<%= f.input :city, class: 'form-control' %>
<%= f.select :state, options_for_select(us_states),{}, class: 'form-control' %>
<%= f.input :description, :label => "Event Description", class: 'form-control' %>
<% if can? :destroy, Event %>
<%= f.select :accepted, [['Accepted', true], ['Not Accepted', false]] %>
<% end %>
<%= f.button :submit, 'Submit' %>
<%= link_to "Back", coin_path(#coin.id), class: "btn btn-default" %>
How do I change this so it stays on the state that it's supposed to?
You can using selected, like:
options_for_select(us_states, selected: "set_current_value")
More usage examples - options_for_select() docs.
I want to check existence of "Name", "Email" input field, but I can't find the method(or function) in parsleyjs.org...
This is my simple-form and parsley code:
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= render 'devise/shared/error_messages', object: f.object %>
<div class="form-inputs">
<%= f.input :name, required: true, autofocus: true%>
<%= f.input :email, required: true %>
<%= f.input :password, required: true, placeholder: "min. 6 characters",
input_html: {"parsley-minlength" => 6, "error-container" =>"#errorBlock"} %>
<%= f.input :password_confirmation, required: true,
input_html: {"parsley-equalto" => "#user_password"} %>
<%= f.collection_select :role, User::ROLES, :to_s, :humanize %>
</div>
<div class="form-actions">
<%= f.button :submit, "회원 가입" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
<script>
$("#new_user").parsley({trigger: "keyup",
errors: {
errorsWrapper: '<div></div>',
errorTemplate: '<span></span>'
}
});
</script>
If I understand correctly your question looking at the comments, it seems that you want to leverage Parsley validation to check in your database if email or name is already taken and display a Parsley error accordingly.
To achieve that, you'll need to use Parsley Remote plugin, and its documentation here: http://parsleyjs.org/doc/index.html#remote
You'll need to work on your APIs to be able to check backend if these fields values already exist in database, and than integrate parsley.remote.js on top of that.
Best
I am trying to create an element in my form that uses simple form+bootstrap. The idea is to allow a user select a type of currency from a drop down.
Customer_currency to select from either USD- US Dollars, LRD - Liberian dollar among others.
I have used the following in my form
However, it is not working, all I see is a drop down (out of position) in my form with the options but no label.
How can i create a good select element with a label using simple form
<%= simple_form_for #customer, :html => { :class => 'form-horizontal' } do |f| %>
<%= f.input :name %>
<%= f.select :customer_currency, [['UGX- Uganda Shillings',1],['USD- US Dollars',2]] %>
<%= f.input :payment_terms %>
<%= f.input :billing_address %>
<%= f.input :first_name %>
<%= f.input :last_name %>
<%= f.input :mobile %>
<%= f.input :email %>
<div class="form-actions">
<%= f.button :submit, :class => 'btn-primary' %>
<%= link_to t('.cancel', :default => t("helpers.links.cancel")),
customers_path, :class => 'btn' %>
</div>
<% end %>
<%= f.input :customer_currency, :collection => [['UGX- Uganda Shillings',1],['USD- US Dollars',2]] %>
Add label_method and value_method to your select, means change:
<%= f.select :customer_currency, [['UGX- Uganda Shillings',1],['USD- US Dollars',2]] %>
to:
<%= f.select :customer_currency, [['UGX- Uganda Shillings',1],['USD- US Dollars',2]], label_method: :first, value_method: :last %>
Update: other solution
<%= f.input :customer_currency, as: :select, [['UGX- Uganda Shillings',1],['USD- US Dollars',2]], label_method: :first, value_method: :last %>
I am using Devise for authentication. Trying to edit/create devise forms with simple_form.
this
<%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name), :html=>{:class=>"form-vertical"}) do |f| %>
<%= f.input :email, :placeholder=>"Email", :label=>false %>
<%= f.input :password, :placeholder=>"Password", :label=>false %>
<% if devise_mapping.rememberable? -%>
<div style="display:inline"><%= f.input :remember_me, :inline_label => 'Yes, remember me'%></div>
<%end -%>
<div><%= f.submit "Sign in", :class=>"pull-right btn btn-primary" %></div>
<div><%= link_to "Create an account", new_user_registration_path%></div>
<% end %>
is literally giving me; Remember Me, which should be checkbox
Maybe use
<%= f.input :remember_me, :as => :boolean %>