I am developing it at Ruby on Rails.
In the form file used for create and update, the wording of the f.submit tag changes automatically depending on whether you want to render with create or update, but I would like to specify that.
However, if I specify the wording, it will appear in both create and update, so I am troubled.
I would like to specify 'registration' when creating and 'modification' when updating, but please let me know if there is any way.
Below is my code.
=form_for@bookdo|f|
div.form-group
.field
= f.label —Number
= f.text_field:BookNum, class: 'form-control', placeholder: 'Enter...'
.
.
.
div.box-footer
.actions
= f. submit 'create book', class: 'btn btn-info pull-right'
Based on how i18n works, I think it would be good to add helpers.submit settings for the book model to config/locales/ja.yml.
http://api.rubyonrails.org/classes/ActionView/Helpers/FormBuilder.html#method-i-submit
=form_for@bookdo|f|
div.form-group
.field
= f.label —Number
= f.text_field:BookNum, class: 'form-control', placeholder: 'Enter...'
.
.
.
div.box-footer
.actions
= f.submit class: 'btn btn-info pull-right'
config/locales/ja.yml
ja:
helpers:
submit:
book:
create: "Register"
update: "Modify"
I have a variable for submit in the controller and switch it over.
app/views/books_controller.rb
...
# GET/books/new
def new
@book=Book.new
@submit='Register'
end
# GET/books/1/edit
default
@submit='Correct'
end
...
app/views/books/_form.html_slim
...
.actions=f.submit@submit
...
© 2024 OneMinuteCode. All rights reserved.