Skip to content

Setting custom view for form field

Lukas Svoboda edited this page Oct 22, 2013 · 1 revision

Classic form

- edit_form.configure do |form|
  - f1 = form.field :project do |f1|
    - f1.options_source = options_task_categories_path
    - f1.html_attributes = { class: 'span3' }

  - f2 = form.default_group.field :task do |f2|
    - param = "f[project_id_eq]"
    - f2.options_source_params = { param => edit_form.resource.project.try(:id) }
    - f2.html_attributes = { class: 'span3', data: { "dependant-filteringselect" => "#item_project", "dependant-param" => param } } 

    - f2.content do
      = form.input :task, label: f1.label, required: f2.required? do
        = form.render_filteringselect f1
        = form.render_filteringselect f2

= form_render edit_form

in app/views/***/_edit.html.haml