Sha256: dc5a3cd5fe9ab0ae4648b343e01990257793c2efe8958db6bf4c445cd48a4b2f
Contents?: true
Size: 1.48 KB
Versions: 22
Compression:
Stored size: 1.48 KB
Contents
# frozen_string_literal: true if defined?(SimpleForm) module Playbook module PbForm class SimpleForm < Playbook::KitBase class FormBuilder < ::SimpleForm::FormBuilder include ::Playbook::PbForm::FormBuilder def input(attribute_name, options = {}, &block) super( attribute_name, options.deep_merge(label: false, input_html: { props: { label: true, }, }), &block ) end end prop :options, type: Playbook::Props::Hash, default: {} prop :validate, type: Playbook::Props::Boolean, default: false def options { builder: Playbook::PbForm::SimpleForm::FormBuilder, html: html_options, data: data, url: "", }.merge(prop(:options)) end def model prop(:options).fetch(:model, nil) end def data prop(:data).merge("pb-form-validation" => validate) end def classname [generate_classname("pb-form"), html[:class]].join(" ") end def html prop(:options).fetch(:html, {}) end def render_form(builder) view_context.capture(builder, &children) end def render_in(view_context, &_block) super(view_context, &nil) end private def html_options html.merge(class: classname) end end end end end
Version data entries
22 entries across 22 versions & 1 rubygems