module TheAdmin::FormHelpers

Public Instance Methods

x_checkbox(id: "", name: "", value: "", label: "", checked: false, switch: false, align: false, inline: false, form_group: true, required: false) click to toggle source

View helper to generate check box @param id [String] the checkbox id attribute @param name [String] the checkbox name attribute @param value [String] the checkbox value @param label [String] the checkbox label @param checked [Boolean] if the checkbox is checked @param switch [Boolean] if the checkbox is a switch @param align [String] if the alignment should be left or right @param inline [Boolean] if the element is inline @param form_group [Boolean] if a form group @param required [Boolean] if required or not @return [String] Compiled html checkbox

# File lib/the-admin/form.rb, line 16
    def x_checkbox(id: "", name: "", value: "", label: "", checked: false, switch: false, align: false, inline: false, form_group: true, required: false)

      checked_output = ""
      switchery_div = ""
      switchery_input = ""
      align_class = ""
      inline_class = ""
      form_group_start = ""
      form_group_end = ""
      required_output = ""

      if checked == true then checked_output='checked="checked"' end
      if switch == true then switchery_div='checkbox-switchery' end
      if switch == true then switchery_input='switch' end
      if align == "left" then align_class='pull-left' end
      if align == "right" then align_class='pull-right' end
      if inline == true then inline_class ='inline' end
      if form_group == true then form_group_start = '<div class="form-group">' end
      if form_group == true then form_group_end = '</div>' end
      if required == true then required_output = "data-parsley-mincheck='1'" end

cb = <<EOS
#{form_group_start}
<div class="checkbox #{switchery_div}">
<label class="#{align_class} #{inline_class}">
<input type="hidden" id="#{id}" name="post[#{name}]" value="0">
<input type="checkbox" class="#{switchery_input}" id="#{id}" name="post[#{name}]" value="1" #{checked_output} data-toggle="checkbox" #{required_output}/>
#{label} </label>
</div>
#{form_group_end}
EOS
      return cb
    end
x_checkbox_string(id: "", name: "", value: "", label: "", checked: false, switch: false, align: false, inline: false, form_group: true, required: false) click to toggle source

Check box helper @param id [String] the checkbox id @param name [String] the name attribute of the checkbox @param value [String] the checkbox value @param label [String] the label text of the checkbox @param checked [Boolean] if the checkbox is checked @param switch [Boolean] if the checkbox is a switchery input @param align [String] if the check box aligned 'left' or 'right' @param inline [Boolean] if the checkbox is inline or not @param form_group [Boolean] if the checkbox is of form group @param required [Boolean] if checkbox is required @return [String] the compiled checkbox

# File lib/the-admin/form.rb, line 62
    def x_checkbox_string(id: "", name: "", value: "", label: "", checked: false, switch: false, align: false, inline: false, form_group: true, required: false)

      checked_output = ""
      switchery_div = ""
      switchery_input = ""
      align_class = ""
      inline_class = ""
      form_group_start = ""
      form_group_end = ""
      required_output = ""

      if checked == true then checked_output='checked="checked"' end
      if switch == true then switchery_div='checkbox-switchery' end
      if switch == true then switchery_input='switch' end
      if align == "left" then align_class='pull-left' end
      if align == "right" then align_class='pull-right' end
      if inline == true then inline_class ='inline' end
      if form_group == true then form_group_start = '<div class="form-group">' end
      if form_group == true then form_group_end = '</div>' end
      if required == true then required_output = "data-parsley-mincheck='1'" end

cb = <<EOS
#{form_group_start}
<div class="checkbox #{switchery_div}">
<label class="#{align_class} #{inline_class}">
<input type="checkbox" class="#{switchery_input}" id="#{id}" name="#{name}" value="#{value}" #{checked_output} data-toggle="checkbox" #{required_output}/>
#{label} </label>
</div>
#{form_group_end}
EOS
      return cb
    end
x_credit_card(id: "", name: "", value: "", label: "", required: false, placeholder: "", maxlength: "16", mask:"") click to toggle source

Credit card input helper @param id [String] credit card input id @param name [String] credit card input name @param value [String] credit card input value @param label [String] credit card label @param required [Boolean] if required or not @param placeholder [String] credit card input placeholder text @param mask [String] credit card input mask @param maxlength [String] nuber input max length @return [String] compiled html of credit card input

# File lib/the-admin/form.rb, line 631
  def x_credit_card(id: "", name: "", value: "", label: "", required: false, placeholder: "", maxlength: "16", mask:"")

    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end

    if label != ""
      label = "<label>#{label}#{required_output} <small>(Numbers Only)</small></label>"
    end

    if mask != ""
      mask = "data-masked-input='#{mask}'"
    end

    if maxlength != ""
      maxlength = "maxlength='#{maxlength}'"
    end

tb = <<EOS
<div class="form-group">
#{label}
<input type="number" pattern="[0-9]{13,16}" class="form-control" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} data-parsley-type="integer" data-parsley-length="[13, 16]" placeholder="#{placeholder}"  #{mask} #{maxlength} />
</div>
EOS
    return tb
  end
x_cvc(id: "", name: "", value: "", label: "", required: false, placeholder: "", maxlength: "4", mask:"999999999999999999") click to toggle source

CVC input helper @param id [String] cvc input id @param name [String] cvc input name @param value [String] cvc input value @param lable [String] cvc label @param required [Boolean] if required or not @param placeholder [String] cvc input placeholder text @param mask [String] cvc input mask @param maxlength [String] nuber input max length @return [String] compiled html of cvc input

# File lib/the-admin/form.rb, line 676
  def x_cvc(id: "", name: "", value: "", label: "", required: false, placeholder: "", maxlength: "4", mask:"999999999999999999")

    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end
    if label != ""
      label = "<label>#{label}</label>"
    end

    if mask != ""
      mask = "data-masked-input='#{mask}'"
    end

    if maxlength != ""
      maxlength = "maxlength='#{maxlength}'"
    end

tb = <<EOS
<div class="form-group">
#{label}#{required_output}
<input type="number" pattern="[0-9]{3,4}" class="form-control" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} data-parsley-type="integer" data-parsley-length="[3, 4]" placeholder="#{placeholder}"  #{mask} #{maxlength} />
</div>
EOS
    return tb
  end
x_date(id: "", name: "", value: "", label: "", required: false, placeholder: "") click to toggle source

Date input helper @param id [String] date input id @param name [String] date input name @param value [String] date input value @param label [String] date input label @param required [Boolean] if required or not @param placeholder [String] date input placeholder text @return [String] compiled html of date input

# File lib/the-admin/form.rb, line 856
  def x_date(id: "", name: "", value: "", label: "", required: false, placeholder: "")

    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end
    if label != ""
      label = "<label for='#{id}' class='control-label'>#{label}</label>"
    end

tb = <<EOS
<div class="form-group">
#{label}#{required_output}
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
<input type="text" class="form-control datepicker" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} placeholder="#{placeholder}"  />
</div>
</div>
EOS
    return tb
  end
x_datetime(id: "", name: "", value: "", label: "", required: false, placeholder: "") click to toggle source

Date-time input helper @param id [String] date-time input id @param name [String] date-time input name @param value [String] date-time input value @param label [String] date-time input label @param required [Boolean] if required or not @param placeholder [String] date-time input placeholder text @return [String] compiled html of date-time input

# File lib/the-admin/form.rb, line 893
  def x_datetime(id: "", name: "", value: "", label: "", required: false, placeholder: "")

    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end
    if label != ""
      label = "<label for='#{id}' class='control-label'>#{label}</label>"
    end

tb = <<EOS
<div class="form-group">
#{label}#{required_output}
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
<input type="text" class="form-control datetimepicker" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} placeholder="#{placeholder}"  />
</div>
</div>
EOS
    return tb
  end
x_ein(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "99-9999999", maxlength: "10") click to toggle source

EIN input helper @param id [String] ein input id @param name [String] ein input name @param value [String] ein input value @param label [String] ein input label @param required [Boolean] if required or not @param placeholder [String] ein input placeholder text @param mask [String] ein input mask @param maxlength [String] nuber input max length @return [String] compiled html of ein input

# File lib/the-admin/form.rb, line 495
  def x_ein(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "99-9999999", maxlength: "10")

    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end

    if label != ""
      label = "<label>#{label}#{required_output}</label>"
    end

    if mask != ""
      mask = "data-masked-input='#{mask}'"
    end

    if maxlength != ""
      maxlength = "maxlength='#{maxlength}'"
    end

tb = <<EOS
<div class="form-group">
#{label}
<input type="text" class="form-control ein" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} data-parsley-minlength="10" placeholder="#{placeholder}" #{mask} #{maxlength} />
</div>
EOS
    return tb
  end
x_email(id: "", name: "", value: "", label: "", required: false, placeholder: "") click to toggle source

Email input helper @param id [String] email input id @param name [String] email input name @param value [String] email input value @param label [String] email input label @param required [Boolean] if required or not @param placeholder [String] email input placeholder text @return [String] compiled html of email input

# File lib/the-admin/form.rb, line 718
  def x_email(id: "", name: "", value: "", label: "", required: false, placeholder: "")

    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end
    if label != ""
      label = "<label>#{label}</label>"
    end

tb = <<EOS
<div class="form-group">
#{label}#{required_output}
<input type="email" class="form-control" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} data-parsley-type="email" placeholder="#{placeholder}" />
</div>
EOS
    return tb
  end
x_exp_month() click to toggle source

Month Drop down

# File lib/the-admin/form.rb, line 1141
  def x_exp_month
    current_year = Time.now.year
    begining_year = Time.now.year - 6

year_dd = <<EOS
<div class="col-md-6">
<div class="form-group">
<label>Expiration Month</label>
<select id="exp_mo" name="post[exp_mo]" class="form-control" data-stripe="exp-month">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</div>
</div>
EOS
  end
x_exp_year() click to toggle source

Year Drop down (expiry)

# File lib/the-admin/form.rb, line 1117
  def x_exp_year
    current_year = Time.now.year
    begining_year = Time.now.year + 6

year_dd = <<EOS
<div class="col-md-6">
<div class="form-group">
<label>Expiration Year</label>
<select id="exp_year" name="post[exp_year]" class="form-control" data-stripe="exp-year">
<option value="#{(current_year)}">#{current_year}</option>
<option value="#{(current_year + 1)}">#{current_year + 1}</option>
<option value="#{(current_year + 2)}">#{current_year + 2}</option>
<option value="#{(current_year + 3)}">#{current_year + 3}</option>
<option value="#{(current_year + 4)}">#{current_year + 4}</option>
<option value="#{(current_year + 5)}">#{current_year + 5}</option>
<option value="#{(current_year + 6)}">#{current_year + 6}</option>
<option value="#{(current_year + 7)}">#{current_year + 7}</option>
</select>
</div>
</div>
EOS
  end
x_file(id:"", name:"", value:"", label:"", required: false, placeholder: "", css: "") click to toggle source

File input helper @param id [String] file input id @param name [String] file input name @param value [String] file input value @param label [String] file input label @param required [Boolean] if required or not @param placeholder [String] file input placeholder text @param css [String] file input css @return [String] compiled html of file input

# File lib/the-admin/form.rb, line 788
  def x_file(id:"", name:"", value:"", label:"", required: false, placeholder: "", css: "")

    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end
    if label != ""
      label = "<label>#{label}</label>"
    end
tb = <<EOS
<div class="form-group">
#{label}#{required_output}
<input type="file" class="form-control file #{css}" id="#{id}" name="filename" value="#{value}" #{required_tag} placeholder="#{placeholder}" />
</div>
EOS
    return tb
  end
x_hidden(id: "", name: "", value: "") click to toggle source

Hidden input helper @param id [String] hidden input id @param name [String] hidden input name @param value [String] hidden input value @return [String] compiled hidden input html

# File lib/the-admin/form.rb, line 142
    def x_hidden(id: "", name: "", value: "")

hi = <<EOS
<input type="hidden" id="#{id}" name="post[#{name}]" value="#{value}"/>
EOS
  return hi
end
x_html(id: "", name: "", value: "", label: "", help: "", required: false) click to toggle source

Summernote @param id [String] summernote id @param name [String] summernote name @param value [String] summernote value @param label [String] summernote label @param required [Boolean] if required or not @return [String] compiled html of summernote

# File lib/the-admin/form.rb, line 1070
  def x_html(id: "", name: "", value: "", label: "", help: "", required: false)

    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end
    if label != ""
      label = "<label for='#{id}'>#{label}</label>"
    end
ta = <<EOS
<div class="form-group">
#{label}
<textarea name="post[#{name}]" id="#{id}" rows="4" class="form-control summernote">#{value}</textarea>
</div>
EOS
    return ta
  end
x_image_upload(id: "input1",name: "input1",value: "",label: "Input1",required: false, size: "1M",height: "",default: "") click to toggle source

Image Upload @param id [String] file input id @param name [String] file input name @param value [String] file input value @param label [String] file input label @param required [Boolean] if required or not @param placeholder [String] file input placeholder text @param css [String] file input css @return [String] compiled html of file input

# File lib/the-admin/form.rb, line 822
  def x_image_upload(id: "input1",name: "input1",value: "",label: "Input1",required: false, size: "1M",height: "",default: "")

    if required && label != ""
      required_output = '<sup class="text-danger">*</sup>'
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end

    if height == ""
      height = ""
    else
      height="data-height='#{height}'"
    end


tb = <<EOS
<div class="form-group">
<label>#{label}</label>
<input type="file" class="form-control file dropify" data-default-file="#{value}" data-max-file-size="#{size}" id="#{id}" name="filename" value="#{value}" #{required_tag} #{height}/>
</div>
EOS
    return tb
  end
x_input(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "", css:"") click to toggle source

Text input helper @param id [String] input element id @param name [String] input element name @param value [String] input element value @param label [String] input element label @param required [Boolean] if input element is required @param placeholder [String] input element placeholder @param mask [String] input element mask @param maxlength [String] input element max length @return [String] compiled input element

# File lib/the-admin/form.rb, line 161
def x_input(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "", css:"")

    id = name unless id != ""
    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end

    if label != ""
      label = "<label>#{label}</label>"
    end

    if maxlength != ""
      maxlength = "maxlength='#{maxlength}'"
    end

    if mask != ""
      mask = "data-masked-input='#{mask}'"
    end

tb = <<EOS
<div class="form-group">
#{label}#{required_output}
<input type="text" class="form-control #{css}" id="#{id}" name="post[#{name}]" value="#{value}" placeholder="#{placeholder}" #{required_tag} #{mask} #{maxlength} />
</div>
EOS
    return tb
  end
x_money(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "") click to toggle source

Money input helper @param id [String] the money input id @param name [String] the money input name @param label [String] the money input label @param required [Boolean] if money input is required or not @param placeholder [String] the moeny input placeholder @param mask [String] the money input mask @param maxlength [String] max length of the input @return [String] compiled money input html

# File lib/the-admin/form.rb, line 207
  def x_money(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "")

    id = name unless id != ""
    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end

    if label != ""
      label = "<label>#{label}</label>"
    end

    if maxlength != ""
      maxlength = "maxlength='#{maxlength}'"
    end

    if mask != ""
      mask = "data-masked-input='#{mask}'"
    end

    if value == 0 || value.nil? || value == ""
      value = "0.00"
    else
      value = "%.2f" % value rescue nil
    end

tb = <<EOS
<div class="form-group">
#{label}#{required_output}
<div class="input-group">
<span class="input-group-addon">$</span>
<input type="text" class="form-control money" id="#{id}" name="post[#{name}]" value="#{value}" placeholder="#{placeholder}" data-parsley-type="number" #{required_tag} #{mask} #{maxlength} />
</div>
</div>
EOS
    return tb
  end
x_number(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "") click to toggle source

Number input helper @param id [String] number input id @param name [String] number input name @param value [String] number input value @param label [String] number input label @param required [Boolean] if required or not @param placeholder [String] number input placeholder text @param mask [String] number input mask @param maxlength [String] nuber input max length @return [String] compiled html of number input

# File lib/the-admin/form.rb, line 360
  def x_number(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "")

    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end

    if label != ""
      label = "<label>#{label}#{required_output}</label>"
    end

    if maxlength != ""
      maxlength = "maxlength='#{maxlength}'"
    end

    if mask != ""
      mask = "data-masked-input='#{mask}'"
    end

tb = <<EOS
<div class="form-group">
#{label}
<input type="text" class="form-control" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag}  placeholder="#{placeholder}" data-parsley-type="number" #{mask} #{maxlength}/>
</div>
EOS
    return tb
  end
x_password(id: "",name: "", value: "", label: "", required: false, placeholder: "") click to toggle source

Password input helper @param id [String] password input id @param name [String] password input name @param value [String] password input value @param label [String] password input label @param required [Boolean] if required or not @param placeholder [String] password input placeholder text @return [String] compiled html of password input

# File lib/the-admin/form.rb, line 968
  def x_password(id: "",name: "", value: "", label: "", required: false, placeholder: "")

    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end
    if label != ""
      label = "<label>#{label}</label>"
    end

tb = <<EOS
<div class="form-group">
#{label}#{required_output}
<input type="password" class="form-control" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} data-parsley-length="[6, 34]" placeholder="#{placeholder}" />
</div>
EOS
    return tb
  end
x_percentage(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "") click to toggle source

Percentage input helper @param id [String] percentage input id @param name [String] percentage input name @param value [String] percentage input value @param label [String] percentage input label @param required [Boolean] if percentage input is required @param placeholder [String] percentage input placeholder @param mask [String] percentage input mask @param maxlength [String] percentage input maxlength

# File lib/the-admin/form.rb, line 261
  def x_percentage(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "")

    id = name unless id != ""
    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end

    if label != ""
      label = "<label>#{label}</label>"
    end

    if maxlength != ""
      maxlength = "maxlength='#{maxlength}'"
    end

    if mask != ""
      mask = "data-masked-input='#{mask}'"
    end

tb = <<EOS
<div class="form-group">
#{label}#{required_output}
<div class="input-group">
<span class="input-group-addon">%</span>
<input type="text" class="form-control" id="#{id}" name="post[#{name}]" value="#{value}" placeholder="#{placeholder}" data-parsley-type="number" #{required_tag} #{mask} #{maxlength} />
</div>
</div>
EOS
    return tb
  end
x_phone(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "(999) 999-9999 x99999", maxlength: "22") click to toggle source

Phone input helper @param id [String] phone input id @param name [String] phone input name @param value [String] phone input value @param label [String] phone input label @param required [Boolean] if required or not @param placeholder [String] phone input placeholder text @param mask [String] phone input mask @param maxlength [String] nuber input max length @return [String] compiled html of phone input

# File lib/the-admin/form.rb, line 407
  def x_phone(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "(999) 999-9999 x99999", maxlength: "22")

    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end

    if label != ""
      label = "<label>#{label}#{required_output}</label>"
    end

    if mask != ""
      mask = "data-masked-input='#{mask}'"
    end

    if maxlength != ""
      maxlength = "maxlength='#{maxlength}'"
    end

tb = <<EOS
<div class="form-group">
#{label}
<input type="text" class="form-control" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag}  placeholder="#{placeholder}" #{mask} #{maxlength} />
</div>
EOS
    return tb
  end
x_radio(id: "", name: "", value: "1", label: "", checked: false, checked_if: "", align: false, inline: false, include_false_as_hidden: false ,form_group: true) click to toggle source

Radio button view helper @param id [String] the radio id @param name [String] the name attribute of the radio @param value [String] the radio value @param label [String] the label text of the radio @param checked [Boolean] if the radio is checked @param align [String] if the check box aligned 'left' or 'right' @param inline [Boolean] if the radio is inline or not @param form_group [Boolean] if the radio is of form group @return [String] the compiled radio

# File lib/the-admin/form.rb, line 106
    def x_radio(id: "", name: "", value: "1", label: "", checked: false, checked_if: "", align: false, inline: false, include_false_as_hidden: false ,form_group: true)

      checked_output = ""
      align_class = ""
      inline_class = ""
      form_group_start = ""
      form_group_end = ""
      include_false_as_hidden_element = ""

      if checked == checked_if then checked_output='checked="checked"' end
      if checked_if != "" then checked = false end
      if checked == true then checked_output='checked="checked"' end
      if align == "left" then align_class='pull-left' end
      if align == "right" then align_class='pull-right' end
      if inline == true then inline_class ='inline' end
      if form_group == true then form_group_start = '<div class="form-group">' end
      if form_group == true then form_group_end = '</div>' end
      if include_false_as_hidden == true then include_false_as_hidden_element = '<input type="hidden" id="#{id}" name="post[#{name}]" value="0">' end
radio_btn = <<EOS
#{form_group_start}
<div class="radio">
<label class="#{align_class} #{inline_class}">
#{include_false_as_hidden_element}
<input type="radio" id="#{id}" name="post[#{name}]" value="#{value}" #{checked_output} data-toggle="radio"/>
#{label}</label>
</div>
#{form_group_end}
EOS
      return radio_btn
    end
x_select(id: "", name: "", value: "",name_col: "name", value_col: "id", label: "", css: "selectpicker", menu_style: "dropdown-blue", style: "btn-default btn-block", option_data: "", option_name: "name", option_value: "id", selected_value: "", title: "", multiple: false, add_none: false, required: false, menu_size: 0, live_search: false) click to toggle source

Select Dropdown @param id [String] id of the select @param name [String] name of the select @param value [String] value of the select @param name_col [String] name col of the select @param value_col [String] vale col of the select @param label [String] label of the select @param css [String] css of the select @param menu_style [String] menu syle of the select @param style [String] style classes of the select @param option_data [String] option data @param option_name [String] option name @param option_value [String] option value @param selected_value [String] selected value of the select @param title [String] title of the select @param multple [Boolean] if multiple selection is enabled @return [String] compiled select drop down

# File lib/the-admin/form.rb, line 1317
  def x_select(id: "", name: "", value: "",name_col: "name", value_col: "id", label: "", css: "selectpicker", menu_style: "dropdown-blue", style: "btn-default btn-block", option_data: "", option_name: "name", option_value: "id", selected_value: "", title: "", multiple: false, add_none: false, required: false, menu_size: 0, live_search: false)

    options_html = ""
    show_multiple = ""
    add_none_option = ""
    live_search_html = ""

    if multiple == true
      show_multiple = "Multiple"
    end

    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end

    multiple_name = ""
    if multiple == true
      multiple_name = "[]"
    end

    option_data.each do |i|
      selected = ""

      if selected_value == i[:id]
        selected = "selected='selected'"
      end

      if selected_value.kind_of?(Array) && (selected_value.include? i[:id])
        selected = "selected='selected'"
      end

      unless name_col.kind_of?(Array)
        options_html << "<option value='#{i[value_col.to_sym]}' #{selected}>#{i[name_col.to_sym]}</option>"
      else

        options_html << "<option value='#{i[value_col.to_sym]}' #{selected}>"
        name_col.each do |n|
          options_html << "#{i[n.to_sym]} "
        end
        options_html << "</option>"

      end
    end

    if option_data.count == 0 || option_data.nil?
      options_html << "<option value=''>No available selections</option>"
    end

    if add_none == true
      add_none_option = "<option value=''>Select One</option>"
    end

    if menu_size == 0
      menu_size_html = ""
    else
      menu_size_html = "data-size='#{menu_size}'"
    end

    if live_search == true
      live_search_html = "data-live-search='true'"
    end

select = <<EOS
<div class="form-group">
<label>#{label}#{required_output}</label>
<select id="#{id}" name="post[#{name}]#{multiple_name}" class="#{css}" data-title="#{title}" title="#{title}" data-style="#{style}" data-menu-style="#{menu_style}" #{show_multiple} #{required_tag} #{menu_size_html} data-container=".content" #{live_search_html}>
#{add_none_option}
#{options_html}
</select>
</div>
EOS

    return select

  end
x_sqft(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "") click to toggle source

Sq Ft input helper @param id [String] percentage input id @param name [String] percentage input name @param value [String] percentage input value @param label [String] percentage input label @param required [Boolean] if percentage input is required @param placeholder [String] percentage input placeholder @param mask [String] percentage input mask @param maxlength [String] percentage input maxlength

# File lib/the-admin/form.rb, line 309
def x_sqft(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "")

    id = name unless id != ""
    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end

    if label != ""
      label = "<label>#{label}</label>"
    end

    if maxlength != ""
      maxlength = "maxlength='#{maxlength}'"
    end

    if mask != ""
      mask = "data-masked-input='#{mask}'"
    end

tb = <<EOS
<div class="form-group">
#{label}#{required_output}
<div class="input-group">
<input type="text" class="form-control sq_ft" id="#{id}" name="post[#{name}]" value="#{value}" placeholder="#{placeholder}" data-parsley-type="number" #{required_tag} #{mask} #{maxlength} />
<span class="input-group-addon">sqft</span>
</div>
</div>
EOS

  return tb
end
x_ssn(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "999-99-9999") click to toggle source

SSN input helper @param id [String] ssn input id @param name [String] ssn input name @param value [String] ssn input value @param label [String] ssn input label @param required [Boolean] if required or not @param placeholder [String] ssn input placeholder text @param mask [String] ssn input mask @param maxlength [String] nuber input max length @return [String] compiled html of ssn input

# File lib/the-admin/form.rb, line 453
  def x_ssn(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "999-99-9999")

    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end

    if label != ""
      label = "<label>#{label}#{required_output}</label>"
    end

    if mask != ""
      mask = "data-masked-input='#{mask}'"
    end


tb = <<EOS
<div class="form-group">
#{label}
<input type="text" class="form-control ssn" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag}  data-parsley-minlength="11" placeholder="#{placeholder}" #{mask} />
</div>
EOS
    return tb
  end
x_state(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "aa", maxlength: "2") click to toggle source

State input helper @param id [String] state input id @param name [String] state input name @param value [String] state input value @param label [String] state input label @param required [Boolean] if required or not @param placeholder [String] state input placeholder text @param mask [String] state input mask @param maxlength [String] nuber input max length @return [String] compiled html of state input

# File lib/the-admin/form.rb, line 585
  def x_state(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "aa", maxlength: "2")

    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end

    if label != ""
      label = "<label>#{label}#{required_output}</label>"
    end

    if mask != ""
      mask = "data-masked-input='#{mask}'"
    end

    if maxlength != ""
      maxlength = "maxlength='#{maxlength}'"
    end

tb = <<EOS
<div class="form-group">
#{label}
<input type="text" class="form-control state" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag}  data-parsley-pattern="^[A-Za-z]*$" data-parsley-minlength="2" placeholder="#{placeholder}"  #{maxlength} />
</div>
EOS
    return tb
  end
x_submit(label: "Submit", css: "btn-primary", icon: "", size: "", wrapper_css: "pull-right") click to toggle source

Submit Helper @param label [String] submit button label @param css [String] submit button css @param icon [String] submit button icon @param size [String] submit button size @param wrapper_css [String] submit button wrapper css @return [String] compiled html of submit button

# File lib/the-admin/form.rb, line 1001
  def x_submit(label: "Submit", css: "btn-primary", icon: "", size: "", wrapper_css: "pull-right")

    if icon != ""
      icon = "<i class='fa #{icon}'></i> "
    end

submit = <<EOS
<div class="form-group form-actions #{wrapper_css}">
<button type="submit" class="btn #{css} #{size}">#{icon}#{label}</button>
</div>
<div class="clearfix"></div>
EOS

    return submit
  end
x_survey_radio(id: "", name: "") click to toggle source

Rating Radios @param id [String] id of the survey radio @param name [String] name of the survey radio @return [String] compiled html of the survey radio

# File lib/the-admin/form.rb, line 1272
  def x_survey_radio(id: "", name: "")
tb = <<EOS
<label class="radio radio-inline">
<input type="radio" id="#{id}" name="#{name}" data-toggle="radio" value="1">
</label>
<label class="radio radio-inline">
<input type="radio" id="#{id}" name="#{name}" data-toggle="radio" value="2">
</label>
<label class="radio radio-inline">
<input type="radio" id="#{id}" name="#{name}" data-toggle="radio" value="3">
</label>
<label class="radio radio-inline">
<input type="radio" id="#{id}" name="#{name}" data-toggle="radio" value="4">
</label>
<label class="radio radio-inline">
<input type="radio" id="#{id}" name="#{name}" data-toggle="radio" value="5">
</label>
<label class="radio radio-inline">
<input type="radio" id="#{id}" name="#{name}" data-toggle="radio" value="6">
</label>
<label class="radio radio-inline">
<input type="radio" id="#{id}" name="#{name}" data-toggle="radio" value="7">
</label>
EOS
    return tb
  end
x_switch(id: "", name: "", value: "", label: "", checked: false) click to toggle source

Switch @param id [String] summernote id @param name [String] summernote name @param value [String] summernote value @param label [String] summernote label @param checked [Boolen] if checked or not @return [String] compiled html of summernote

# File lib/the-admin/form.rb, line 1175
  def x_switch(id: "", name: "", value: "", label: "", checked: false)

    checked_output = ""

    if checked == true then checked_output='checked="checked"' end

cb = <<EOS
<div class="form-group">
<label>#{label}</label><br>
<div class="switch"
data-on-label="<i class='fa fa-check'></i>"
data-off-label="<i class='fa fa-times'></i>">
<input type="hidden" id="#{id}" name="post[#{name}]" value="0">
<input type="checkbox" id="#{id}" name="post[#{name}]" value="1" #{checked_output}/>
</div>
</div>
EOS
    return cb
  end
x_tags(id: "", name: "", value: "", label: "", required: false, placeholder: "") click to toggle source

Tags @param id [String] tags id @param name [String] tags name @param value [String] tags value @param label [String] tags label @param required [Boolean] if required or not @param placeholder [String] tags placeholder text @return [String] compiled html of tags

# File lib/the-admin/form.rb, line 1203
  def x_tags(id: "", name: "", value: "", label: "", required: false, placeholder: "")

    id = name unless id != ""
    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end

    if label != ""
      label = "<label>#{label}</label>"
    end
tb = <<EOS
<div class="form-group">
#{label}#{required_output}
<input type="text" class="form-control tagsinput typeahead tag-azure tag-fill" id="#{id}" name="post[#{name}]" value="#{value}" placeholder="#{placeholder}" #{required_tag}/>
</div>
EOS
    return tb
  end
x_textarea(id: "", name: "", value: "",label: "",placeholder: "",required: false, maxlength:"") click to toggle source

Text Area Helper @param id [String] textarea id @param name [String] textarea name @param value [String] textarea value @param placeholder [String] textarea placeholder text @param label [String] textarea label @param required [Boolean] if required or not @param maxlength [String] textarea max length @return [String] compiled html of textarea

# File lib/the-admin/form.rb, line 1028
  def x_textarea(id: "", name: "", value: "",label: "",placeholder: "",required: false, maxlength:"")

    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end

    if label != ""
      label = "<label for='#{id}'>#{label}</label>"
    end

    if label != ""
      label = "<label for='#{id}'>#{label}</label>"
    end

    if maxlength != ""
      maxlength = "maxlength='#{maxlength}'"
    end

ta = <<EOS
<div class="form-group">
#{label}#{required_output}
<textarea name="post[#{name}]" id="#{id}" rows="4" class="form-control" placeholder="#{placeholder}" #{maxlength} #{required_tag}>#{value}</textarea>
</div>
EOS
    return ta
  end
x_time(id: "", name: "", value: "", label: "", required: false, placeholder: "") click to toggle source

Time input helper @param id [String] time input id @param name [String] time input name @param value [String] time input value @param label [String] time input label @param required [Boolean] if required or not @param placeholder [String] time input placeholder text @return [String] compiled html of time input

# File lib/the-admin/form.rb, line 930
  def x_time(id: "", name: "", value: "", label: "", required: false, placeholder: "")

    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end
    if label != ""
      label = "<label for='#{id}' class='control-label'>#{label}</label>"
    end

tb = <<EOS
<div class="form-group">
#{label}#{required_output}
<div class="input-group">
<span class="input-group-addon"><i class="fa fa fa-clock-o"></i></span>
<input type="text" class="form-control timepicker" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} placeholder="#{placeholder}"  />
</div>
</div>
EOS
    return tb
  end
x_typeahead(id: "", name: "", value: "", label: "", required: false, placeholder: "", css: "") click to toggle source

Typeahead @param id [String] typeahead id @param name [String] typeahead name @param value [String] typeahead value @param label [String] typeahead label @param required [Boolean] if required or not @param placeholder [String] typeahead placeholder text @param css [String] typeahead css @return [String] compiled html of typeahead

# File lib/the-admin/form.rb, line 1240
  def x_typeahead(id: "", name: "", value: "", label: "", required: false, placeholder: "", css: "")

    id = name unless id != ""
    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end

    if label != ""
      label = "<label>#{label}</label>"
    end
tb = <<EOS
<div class="form-group">
#{label}#{required_output}
<input type="text" class="form-control typeahead #{css}" autocomplete="off" id="#{id}" name="post[#{name}]" value="#{value}" placeholder="#{placeholder}" #{required_tag}/>
</div>
EOS
    return tb
  end
x_url(id:"", name:"", value:"", label:"", required: false, placeholder: "") click to toggle source

URL input helper @param id [String] url input id @param name [String] url input name @param value [String] url input value @param label [String] url input label @param required [Boolean] if required or not @param placeholder [String] url input placeholder text @return [String] compiled html of url input

# File lib/the-admin/form.rb, line 753
  def x_url(id:"", name:"", value:"", label:"", required: false, placeholder: "")

    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end
    if label != ""
      label = "<label>#{label}</label>"
    end

tb = <<EOS
<div class="form-group">
#{label}#{required_output}
<input type="url" class="form-control" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag} data-parsley-type="url" placeholder="#{placeholder}"   />
</div>
EOS
    return tb
  end
x_year() click to toggle source

Year Drop down

# File lib/the-admin/form.rb, line 1098
  def x_year
    current_year = Time.now.year

year_dd = <<EOS
<select id="selected_year" name="selected_year" class="selectpicker" data-style="btn-primary btn" data-width="auto">
<option selected="selected" value="#{current_year}">#{current_year}</option>
<option value="#{current_year - 1}">#{current_year - 1}</option>
<option value="#{current_year - 2}">#{current_year - 2}</option>
<option value="#{current_year - 3}">#{current_year - 3}</option>
<option value="#{current_year - 4}">#{current_year - 4}</option>
<option value="#{current_year - 5}">#{current_year - 5}</option>
<option value="#{current_year - 6}">#{current_year - 6}</option>
<option value="#{current_year - 7}">#{current_year - 7}</option>
</select>
EOS
  end
x_zip(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "99999", maxlength: "5") click to toggle source

Zip input helper @param id [String] zip input id @param name [String] zip input name @param value [String] zip input value @param label [String] zip input label @param required [Boolean] if required or not @param placeholder [String] zip input placeholder text @param mask [String] zip input mask @param maxlength [String] nuber input max length @return [String] compiled html of zip input

# File lib/the-admin/form.rb, line 540
  def x_zip(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "99999", maxlength: "5")

    if required
      if label != ""
        required_output = '<sup class="text-danger">*</sup>'
      else
        required_output = ''
      end
      required_tag = 'required="required"'
    else
      required_output = ""
      required_tag = ""
    end

    if label != ""
      label = "<label>#{label}#{required_output}</label>"
    end

    if mask != ""
      mask = "data-masked-input='#{mask}'"
    end

    if maxlength != ""
      maxlength = "maxlength='#{maxlength}'"
    end

tb = <<EOS
<div class="form-group">
#{label}
<input type="text" class="form-control zip" id="#{id}" name="post[#{name}]" value="#{value}" #{required_tag}  placeholder="#{placeholder}" #{mask} data-parsley-length="[5,5]" data-parsley-length-message="This value should be exactly 5 digits long" data-parsley-type="digits"  />
</div>
EOS
    return tb
  end