{"id":13747515,"url":"https://github.com/eploko/simple_form-magic_submit","last_synced_at":"2025-05-09T08:33:20.649Z","repository":{"id":7560867,"uuid":"8914464","full_name":"eploko/simple_form-magic_submit","owner":"eploko","description":"A smart submit button extension for the Simple Form gem.","archived":true,"fork":false,"pushed_at":"2014-03-19T14:24:20.000Z","size":374,"stargazers_count":12,"open_issues_count":1,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-03-11T18:08:29.923Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://eploko.github.com/simple_form-magic_submit","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eploko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-20T21:07:38.000Z","updated_at":"2023-01-28T11:53:21.000Z","dependencies_parsed_at":"2022-09-01T18:44:24.503Z","dependency_job_id":null,"html_url":"https://github.com/eploko/simple_form-magic_submit","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eploko%2Fsimple_form-magic_submit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eploko%2Fsimple_form-magic_submit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eploko%2Fsimple_form-magic_submit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eploko%2Fsimple_form-magic_submit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eploko","download_url":"https://codeload.github.com/eploko/simple_form-magic_submit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253217316,"owners_count":21873067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T06:01:31.982Z","updated_at":"2025-05-09T08:33:20.378Z","avatar_url":"https://github.com/eploko.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Magic Submit Button for Simple Form\n\n[![Dependency Status](https://gemnasium.com/eploko/simple_form-magic_submit.png)](https://gemnasium.com/eploko/simple_form-magic_submit)\n\nA smart submit button extension for the Simple Form gem that:\n\n- Displays an alternate title on validation errors.\n- Displays a different \"Loading...\" title depending on whether the model is being created or updated.\n- Is optionally postfixed with a \"Cancel\" link.\n- Is fully localizable via the I18n gem.\n\n## A picture's worth a thousand words, right?\n\nFor a newly created model object, typically in a `new.html.haml`:\n\n\u003cimg src=\"https://raw.github.com/eploko/simple_form-magic_submit/master/preview/01-submit.png\" width=\"720\" height=\"190\" alt=\"A preview of the submit button in the simples case.\"/\u003e\n\nAdd a cancel link:\n\n\u003cimg src=\"https://raw.github.com/eploko/simple_form-magic_submit/master/preview/02-submit-with-cancel.png\" width=\"720\" height=\"190\" alt=\"A preview of the submit button accompanied by a Cancel link.\"/\u003e\n\nWhen something goes wrong and the model fails validation:\n\n\u003cimg src=\"https://raw.github.com/eploko/simple_form-magic_submit/master/preview/03-model-invalid.png\" width=\"720\" height=\"260\" alt=\"A preview of the submit button with a different title when the validation has failed.\"/\u003e\n\nAnd all this and a bit more with just a single line of code:\n\n```haml\n= f.button :magic_submit, cancel: root_path\n```\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'simple_form-magic_submit'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install simple_form-magic_submit\n\n## Usage\n\nIn your view template add it allong the lines of:\n\n```haml\n= simple_form_for(resource) do |f|\n    = f.error_notification\n    .form-inputs\n        = f.input :email, autofocus: true\n    .form-actions\n        = f.button :magic_submit\n```\n\nThe last one is this gem's magic.\n\nTo add a cancel link:\n\n```haml\n= simple_form_for(resource) do |f|\n    = f.error_notification\n    .form-inputs\n        = f.input :email, autofocus: true\n    .form-actions\n        = f.button :magic_submit, cancel: root_path\n```\n\nReplace `root_path` with whatever path is relevant for your app.\n\n## Localization\n\nThe gem comes bundled with an English translation in [en.yml](https://github.com/eploko/simple_form-magic_submit/blob/master/locales/en.yml):\n\n```yaml\nen:\n  simple_form:\n    magic_submit:\n      default:\n        new:\n          submit: \"Create a new %{model}\"\n          retry: \"Try creating once again\"\n          disable_with: \"Creating\u0026#133;\"\n        edit:\n          submit: \"Save changes\"\n          retry: \"Try saving once again\"\n          disable_with: \"Saving\u0026#133;\"\n      cancel:\n        format: \"%{submit_button} or %{cancel_link}\"\n        cancel: \"Cancel\"\n```\n\nSimply copy the file to you `config/locales` folder inside your Rails project if you want to change the default strings.\n\nSay, for the title the keys will be looked up in the following order:\n\n1. `simple_form.magic_submit.namespace_name.controller_name.model_name.action.submit`\n2. `simple_form.magic_submit.namespace_name.controller_name.action.submit`\n3. `simple_form.magic_submit.default.action.submit`\n4. `helpers.submit.action`\n\nSay, for a `Admin::UsersController` and a `Roles` model, the following lookups will be\nmade on the edit action:\n\n1. `simple_form.magic_submit.admin.users.roles.edit.submit`\n2. `simple_form.magic_submit.admin.users.edit.submit`\n3. `simple_form.magic_submit.default.edit.submit`\n4. `helpers.submit.edit`\n\nEach lookup will have `%{model}` interpolated to the name of the model.\n\n## To-do\n\n1. Add tests.\n2. Add more translations.\n3. You tell me.\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n## Thanks go to...\n\nVictor Nahuel Chaves (https://github.com/nahue) for adding support for model-less forms.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feploko%2Fsimple_form-magic_submit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feploko%2Fsimple_form-magic_submit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feploko%2Fsimple_form-magic_submit/lists"}