Module: WebFlow::BaseHelper

Defined in:
lib/webflow/base_helper.rb

Instance Method Summary collapse

Instance Method Details

#end_flow_form_tagObject

Alias for Rails standard end_form_tag



253
254
255
# File 'lib/webflow/base_helper.rb', line 253

def end_flow_form_tag
  end_form_tag
end

#flow_button_tag(content_or_options = nil, options = nil, &block) ⇒ Object

Helper method to generate a button element. This is a wrapper method for the Rails button_tag method. It adds a data-remote attribute, if specified, to enable an UJS ajax submission.

Parameters:

  • content_or_options (defaults to: nil)
  • options (defaults to: nil)
  • block


210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/webflow/base_helper.rb', line 210

def flow_button_tag(content_or_options = nil, options = nil, &block)
  options = content_or_options if block_given? && content_or_options.is_a?(Hash)
  options ||= {}
  options.stringify_keys!

  if remote = options.delete("remote")
    options["data-remote"] = remote
  end

  if event = options.delete("event")
    options["name"] = WebFlow::Base.event_input_name_prefix + WebFlow::Base.event_prefix + event.to_s
    options["value"] = WebFlow::Base.event_prefix + event.to_s
  end

  button_tag content_or_options, options, &block
end

#flow_form_tag(url_for_options = {}, options = {}, &block) ⇒ Object



187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/webflow/base_helper.rb', line 187

def flow_form_tag(url_for_options = {}, options = {}, &block)
  content =
      if block_given?
        form_tag url_for_options, options, &block
      else
        form_tag url_for_options, options
      end

  content << hidden_field_tag(WebFlow::Base.flow_execution_key_id, @flow_id)

  content
end

#flow_key_tagObject

Helper method to generate a hidden input tag for the flow execution key.



182
183
184
# File 'lib/webflow/base_helper.rb', line 182

def flow_key_tag
  hidden_field_tag WebFlow::Base.flow_execution_key_id, @flow_id
end

Helper method to generate an HTML anchor element. This method is a wrapper for the Rails link_to method.

Parameters:

  • args

    options, event_name, html_options

  • block

    optional block



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/webflow/base_helper.rb', line 235

def flow_link_to(*args, &block)
  if block_given?
    options = args.first || {}
    event_name = args.second
    html_options = args.third
    flow_link_to(capture(&block), event_name, options, html_options)
  else
    name = args[0]
    event_name = args[1]
    options = args[2] || {}
    html_options = args[3]

    html_options[:method] = 'GET'
    link_to name, append_flow_params(options, event_name), html_options
  end
end

#get_flow_data(key) ⇒ Object



258
259
260
# File 'lib/webflow/base_helper.rb', line 258

def get_flow_data(key)
  controller.current_flow_user_data[key]
end