Module: Decidim::Blogs::PostsSelectHelper

Includes:
ApplicationHelper, SanitizeHelper
Defined in:
app/helpers/decidim/blogs/posts_select_helper.rb

Overview

Custom helpers used in posts views

Instance Method Summary collapse

Instance Method Details

#fo_post_author_select_field(form, name, _options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'app/helpers/decidim/blogs/posts_select_helper.rb', line 10

def (form, name, _options = {})
  select_options = [
    [current_user.name, current_user.id]
  ]

  select_options << [form.object.author.name, form.object.author.id] unless !form.object.author || select_options.pluck(1).include?(form.object.author.id)

  return form.select(name, select_options) if select_options.size > 1

  form.hidden_field(name, value: select_options.first[1])
end