3.5.0






Form

Default (Form With)

Please enter the first name

Close
<%
  example_collection = [
    OpenStruct.new(name: "Alabama", value: 1),
    OpenStruct.new(name: "Alaska", value: 2),
    OpenStruct.new(name: "Arizona", value: 3),
    OpenStruct.new(name: "Arkansas", value: 4),
    OpenStruct.new(name: "California", value: 5),
    OpenStruct.new(name: "Colorado", value: 6),
    OpenStruct.new(name: "Connecticut", value: 7),
    OpenStruct.new(name: "Delaware", value: 8),
    OpenStruct.new(name: "Florida", value: 9),
    OpenStruct.new(name: "Georgia", value: 10),
  ]
%>

<%= pb_rails("form", props: { form_system_options: { scope: :example, method: :get } }) do |form| %>
  <%= form.text_field :example_text_field, props: { error: "Please enter the first name", label: true } %>
  <%= form.telephone_field :example_phone_field, props: { label: true } %>
  <%= form.email_field :example_email_field, props: { label: true } %>
  <%= form.number_field :example_number_field, props: { label: true } %>
  <%= form.search_field :example_search_field, props: { label: true } %>
  <%= form.password_field :example_password_field, props: { label: true } %>
  <%= form.url_field :example_url_field, props: { label: true } %>
  <%= form.text_area :example_text_area, props: { label: true } %>
  <%= form.select :example_select, [ ["Yes", 1], ["No", 2] ], props: { label: true } %>
  <%= form.collection_select :example_collection_select, example_collection, :value, :name, props: { label: true } %>

  <%= form.actions do |action| %>
    <%= action.submit %>
    <%= action.button props: { type: "reset", text: "Cancel", variant: "secondary" } %>
  <% end %>
<% end %>
Default (Simple Form)

Please enter a valid first name

Close
<%
  require "simple_form" unless defined?(SimpleForm)
  require "active_model/railtie" unless defined?(ActiveModel)

  example_form_model = Class.new do
    include ::ActiveModel::Model
    attr_accessor :example_text_field,
    :example_phone_field,
    :example_email_field,
    :example_number_field,
    :example_search_field,
    :example_password_field,
    :example_url_field,
    :example_text_area,
    :example_select_field,
    :example_collection_select_field


    def self.model_name
      ActiveModel::Name.new(self, nil, "ExampleFormModel")
    end
  end
%>

<%
  example_collection = [
    OpenStruct.new(name: "Alabama", value: 1),
    OpenStruct.new(name: "Alaska", value: 2),
    OpenStruct.new(name: "Arizona", value: 3),
    OpenStruct.new(name: "Arkansas", value: 4),
    OpenStruct.new(name: "California", value: 5),
    OpenStruct.new(name: "Colorado", value: 6),
    OpenStruct.new(name: "Connecticut", value: 7),
    OpenStruct.new(name: "Delaware", value: 8),
    OpenStruct.new(name: "Florida", value: 9),
    OpenStruct.new(name: "Georgia", value: 10),
  ]
%>


<%= pb_rails("form", props: { form_system: "simple_form", form_system_options: [example_form_model.new, url: "", method: :get] }) do |form| %>
  <%= form.input :example_text_field, {as: :string, input_html: {props: {error: "Please enter a valid first name"}}} %>
  <%= form.input :example_phone_field, as: :tel %>
  <%= form.input :example_email_field, as: :email %>
  <%= form.input :example_number_field, as: :integer %>
  <%= form.input :example_search_field, as: :search %>
  <%= form.input :example_password_field, as: :password %>
  <%= form.input :example_url_field, as: :url %>
  <%= form.input :example_text_area, as: :text %>
  <%= form.select :example_select_field, [["Yes", 1], ["No", 2]], props: { label: true } %>
  <%= form.collection_select :example_collection_select_field, example_collection, :value, :name, props: { label: true } %>

  <%= form.actions do |action| %>
    <%= action.submit %>
    <%= action.button props: { type: "reset", text: "Cancel", variant: "secondary" } %>
  <% end %>
<% end %>
Available Props
form_system
form_system_options
children