Skip to content

Allow default option for disabled-with part two #329

Open
@abitdodgy

Description

@abitdodgy

Rails has a great feature for translating button text. We can write this:

/posts/_form.html.slim
= f.submit class: 'button'

This feature allows us to reuse partials in new and edit templates with no logic. Rails automatically substitutes the button text based on your en.yml file.

en:
  helpers:
    submit:
      post:
        create: "New"
        update: "Save"

Now, if you want to disable the button state and still reuse your partial, you have to use some ugly logic:

- if @post.new_record?
  = f.submit class: 'btn', 'data-disable-with' => t('helpers.submit.post.create')
- else
  = f.submit class: 'btn', 'data-disable-with' => t('helpers.submit.post.update')

Which defeats the point. It would be nice to have a a disabled-with-default option that just disables the button with its existing text. Something like:

= f.submit class: 'button', 'disable-with-default'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions