debian-mirror-gitlab/app/views/shared/_field.html.haml

30 lines
1.4 KiB
Text
Raw Normal View History

2015-09-11 14:41:01 +05:30
- name = field[:name]
- title = field[:title] || name.humanize
- value = @service.send(name)
- type = field[:type]
- placeholder = field[:placeholder]
2020-06-23 00:09:42 +05:30
- autocomplete = field[:autocomplete]
2017-09-10 17:25:29 +05:30
- required = field[:required]
2015-09-11 14:41:01 +05:30
- choices = field[:choices]
- default_choice = field[:default_choice]
- help = field[:help]
2018-11-08 19:23:39 +05:30
.form-group.row
2015-10-24 18:46:33 +05:30
- if type == "password" && value.present?
2020-05-24 23:13:21 +05:30
= form.label name, _("Enter new %{field_title}") % { field_title: title.downcase }, class: "col-form-label col-sm-2"
2015-10-24 18:46:33 +05:30
- else
2018-11-08 19:23:39 +05:30
= form.label name, title, class: "col-form-label col-sm-2"
2015-09-11 14:41:01 +05:30
.col-sm-10
- if type == 'text'
2020-06-23 00:09:42 +05:30
= form.text_field name, class: "form-control", autocomplete: autocomplete, placeholder: placeholder, required: required, data: { qa_selector: "#{name.downcase.gsub('\s', '')}_field" }
2015-09-11 14:41:01 +05:30
- elsif type == 'textarea'
2020-05-24 23:13:21 +05:30
= form.text_area name, rows: 5, class: "form-control", placeholder: placeholder, required: required
2015-09-11 14:41:01 +05:30
- elsif type == 'checkbox'
2020-05-24 23:13:21 +05:30
= form.check_box name
2015-09-11 14:41:01 +05:30
- elsif type == 'select'
2020-07-28 23:09:34 +05:30
= form.select name, options_for_select(choices, value || default_choice), {}, { class: "form-control"}
2015-09-11 14:41:01 +05:30
- elsif type == 'password'
2020-05-24 23:13:21 +05:30
= form.password_field name, autocomplete: "new-password", placeholder: placeholder, class: "form-control", required: value.blank? && required, data: { qa_selector: "#{name.downcase.gsub('\s', '')}_field" }
2015-09-11 14:41:01 +05:30
- if help
2018-11-08 19:23:39 +05:30
%span.form-text.text-muted= help