Sha256: 0bd4b28027454746cd72656aac36afa9a1ea786fed9792f4abd24805324bf7ce

Contents?: true

Size: 1.67 KB

Versions: 5

Compression:

Stored size: 1.67 KB

Contents

- value = defined?(value).present? ? value : ''
- case field.field_type
- when 'text', 'string', 'numeric', 'date_picker'
  - if value.present?
    = f.input field.title.to_sym, as: field.field_type, input_html: { class: class_name, id: "#{class_name}_#{field.title}", name: "#{class_name}[#{field.title}]", value: value }
  - else
    = f.input field.title.to_sym, as: field.field_type, input_html: { class: class_name, id: "#{class_name}_#{field.title}", name: "#{class_name}[#{field.title}]" }
- when 'select'
  - parsed_json = field.options.is_a?(Hash) ? field.options : (JSON.parse(field.options) unless field.options == '')
  - if parsed_json && parsed_json.dig('collection', 'name')
    - if value.present?
      = f.input field.title.to_sym, as: :select, collection: collection_list_by(name: parsed_json['collection']['name']), input_html: { class: class_name, id: "#{class_name}_#{field.title}", name: "#{class_name}[#{field.title}]" }, selected: value
    - else
      = f.input field.title.to_sym, as: :select, collection: collection_list_by(name: parsed_json['collection']['name']), input_html: { class: class_name, id: "#{class_name}_#{field.title}", name: "#{class_name}[#{field.title}]" }
  - else
    - if value.present?
      = f.input field.title.to_sym, as: :select, input_html: { class: class_name, id: "#{class_name}_#{field.title}", name: "#{class_name}[#{field.title}]" }, selected: value
    - else
      = f.input field.title.to_sym, as: :select, input_html: { class: class_name, id: "#{class_name}_#{field.title}", name: "#{class_name}[#{field.title}]" }
- if params[:errors].present? && params[:errors][field.title]&.first
  .alert.alert-danger
    = params[:errors][field.title]&.first

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tramway-core-1.13.0.1 app/views/tramway/core/shared/_input_extended.html.haml
tramway-core-1.13 app/views/tramway/core/shared/_input_extended.html.haml
tramway-core-1.12.1 app/views/tramway/core/shared/_input_extended.html.haml
tramway-core-1.12.0.2 app/views/tramway/core/shared/_input_extended.html.haml
tramway-core-1.12.0.1 app/views/tramway/core/shared/_input_extended.html.haml