You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

54 lines
2.1 KiB

# frozen_string_literal: true
# This file was generated by QuestionsCrafter
# Generated at: <%= Time.now.strftime("%Y-%m-%d %H:%M:%S") %>
class <%= class_name %>
include QuestionsCrafter::Dsl
# The following are used by the questions_crafter to display the form title and description
title "<%= class_name.demodulize.titleize %>"
description "Add a description for the form"
# Used by the questions_crafter to generate the back link
back_link "/root-to-back"
# --------------------------------------------------------------------
# Examples of how to define questions:
#
# question :name, as: :string, title: "Name", description: "Enter your full name", required: true
# validates :name, length: { in: 3..50, message: "must be between 3 and 50 characters" }
#
# question :email, as: :string, title: "Email", description: "We'll use this to contact you", required: true
# validates :email, format: { with: URI::MailTo::EMAIL_REGEXP, message: "must be a valid email" }
#
# question :message, as: :text, title: "Message", description: "Tell us what you think"
#
# question :gender, as: :radio,
# title: "Gender",
# options: { "M" => "Male", "F" => "Female", "O" => "Other" },
# required: true
#
# question :age, as: :integer,
# title: "Age"
#
# question :country, as: :select,
# title: "Country",
# options: { "US" => "United States", "AR" => "Argentina" },
# required: true
#
# question :interests, as: :checkbox_group,
# title: "Interests",
# options: { "sports" => "Sports", "music" => "Music", "books" => "Books" }
#
# question :accept_terms, as: :boolean,
# title: "I accept the terms and conditions",
# required: true
# --------------------------------------------------------------------
<% if @parsed_questions.any? -%>
# Questions defined from generator
<% @parsed_questions.each do |question| -%>
question :<%= question[:name] %>, as: :<%= question[:type] %>, title: "<%= question[:title] %>"<%=
", options: { \"1\" => \"Option 1\", \"2\" => \"Option 2\", \"3\" => \"Option 3\" }" if question[:has_options]
%>
<% end -%><% end -%>
end