class Primer::Alpha::ActionList::FormWrapper

Utility component for wrapping ActionLists or individual ActionList::Items in forms.

def extract_http_method(args)

def extract_http_method(args)
  if (http_method = args.delete(:method))
    HTTP_METHOD_OPTIONS.include?(http_method) ? http_method : DEFAULT_HTTP_METHOD
  else
    DEFAULT_HTTP_METHOD
  end
end

def form_required?

def form_required?
  @action && !get?
end

def get?

def get?
  @http_method == :get
end

def initialize(list:, action: nil, **form_arguments)

def initialize(list:, action: nil, **form_arguments)
  @list = list
  @form_arguments = form_arguments
  @action = action
  @http_method = extract_http_method(@form_arguments)
  name = @form_arguments.delete(:name)
  value = @form_arguments.delete(:value) || name
  @input_arguments = {
    type: :hidden,
    name: name,
    value: value,
    data: { list_item_input: true },
    **(@form_arguments.delete(:input_arguments) || {})
  }
end

def render_input?

def render_input?
  @input_arguments[:name].present?
end