class Phlex::Rails::Form
def self.input_field(method_name, type:)
def self.input_field(method_name, type:) define_method method_name do |field, value: @model.attributes[field.to_s], **attributes| input( name: field_name(field), type: type, value: value, **attributes ) end end
def authenticity_token_field
def authenticity_token_field input( name: "authenticity_token", type: "hidden", value: @_view_context.form_authenticity_token ) end
def field_name(*field)
def field_name(*field) @_view_context.field_name(ActiveModel::Naming.param_key(@model.class), *field) end
def initialize(model)
def initialize(model) @model = model end
def submit(value)
def submit(value) input( name: "commit", type: "submit", value: value ) end
def template(&block)
def template(&block) form action: @url, method: @method do authenticity_token_field yield_content(&block) end end
def url
def url @_view_context.url_for(@model) end