Sha256: ba51756656a81489cef8e2f6e97b4ab30c8e38e4a52c63e9e62764e30a1b811c

Contents?: true

Size: 633 Bytes

Versions: 14

Compression:

Stored size: 633 Bytes

Contents

class <%= @p_class_name %>FormSection < Prime::FormSection
  field :title,
    label: { text: 'Title' },
    input: {
      text: proc { model.title },
      placeholder: "Enter title here"
    }

  field :delete, type: :submit,
    button: {
      title: "Delete",
      background_color: :red
    },
    action: :on_delete,
    if: proc { model.persisted? }

  field :submit, type: :submit,
    button: { title: "Save" },
    action: :on_submit

  def on_delete
    model.delete
    screen.close_screen(to_root: true)
  end

  def on_submit
    model.assign_attributes(field_values)
    model.save
    screen.close_screen
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
motion-prime-1.0.7 generators/templates/scaffold/form.rb
motion-prime-1.0.6 generators/templates/scaffold/form.rb
motion-prime-1.0.5 generators/templates/scaffold/form.rb
motion-prime-1.0.4 generators/templates/scaffold/form.rb
motion-prime-1.0.3 generators/templates/scaffold/form.rb
motion-prime-1.0.2 generators/templates/scaffold/form.rb
motion-prime-1.0.1 generators/templates/scaffold/form.rb
motion-prime-1.0.0 generators/templates/scaffold/form.rb
motion-prime-0.9.9.2 generators/templates/scaffold/form.rb
motion-prime-0.9.9.1 generators/templates/scaffold/form.rb
motion-prime-0.9.9 generators/templates/scaffold/form.rb
motion-prime-0.9.8 generators/templates/scaffold/form.rb
motion-prime-0.9.7 generators/templates/scaffold/form.rb
motion-prime-0.9.6 generators/templates/scaffold/form.rb