lib/express_templates/components/forms/submit.rb in express_templates-0.7.1 vs lib/express_templates/components/forms/submit.rb in express_templates-0.8.0
- old
+ new
@@ -1,25 +1,29 @@
module ExpressTemplates
module Components
module Forms
class Submit < FormComponent
- def build(*args)
- div(class: field_wrapper_class) {
- if args.first.is_a?(String) or args.empty?
- submit_tag(args.first || 'Save', (args[1]||{}))
- else
- submit_tag 'Save', (args.first || {})
- end
- }
- end
+ has_option :button_class, 'The css class of the input button.'
+ has_option :value, 'The value of the submit tag. Text show in button.',
+ default: 'Save'
- def value
- if @args.first.is_a?(String)
- @args.first
- else
- 'Save'
+ contains -> {
+ submit_tag(value, input_attributes)
+ }
+
+ before_build -> {
+ # if we are not part of a form, we don't get a default id
+ begin
+ super()
+ rescue
+ add_class(config[:class])
+ remove_class('submit')
end
+ }
+
+ def value
+ config[:value]
end
end
end
end