Module: TheAdmin::FormHelpers

Defined in:
lib/the-admin/form.rb

Instance Method Summary collapse

Instance Method Details

#x_checkbox(id: "", name: "", value: "", label: "", checked: false, switch: false, align: false, inline: false, form_group: true, required: false) ⇒ String

View helper to generate check box

Parameters:

  • id (String) (defaults to: "")

    the checkbox id attribute

  • name (String) (defaults to: "")

    the checkbox name attribute

  • value (String) (defaults to: "")

    the checkbox value

  • label (String) (defaults to: "")

    the checkbox label

  • checked (Boolean) (defaults to: false)

    if the checkbox is checked

  • switch (Boolean) (defaults to: false)

    if the checkbox is a switch

  • align (String) (defaults to: false)

    if the alignment should be left or right

  • inline (Boolean) (defaults to: false)

    if the element is inline

  • form_group (Boolean) (defaults to: true)

    if a form group

  • required (Boolean) (defaults to: false)

    if required or not

Returns:

  • (String)

    Compiled html checkbox



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# 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) ⇒ String

Check box helper

Parameters:

  • id (String) (defaults to: "")

    the checkbox id

  • name (String) (defaults to: "")

    the name attribute of the checkbox

  • value (String) (defaults to: "")

    the checkbox value

  • label (String) (defaults to: "")

    the label text of the checkbox

  • checked (Boolean) (defaults to: false)

    if the checkbox is checked

  • switch (Boolean) (defaults to: false)

    if the checkbox is a switchery input

  • align (String) (defaults to: false)

    if the check box aligned ‘left’ or ‘right’

  • inline (Boolean) (defaults to: false)

    if the checkbox is inline or not

  • form_group (Boolean) (defaults to: true)

    if the checkbox is of form group

  • required (Boolean) (defaults to: false)

    if checkbox is required

Returns:

  • (String)

    the compiled checkbox



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# 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: "") ⇒ String

Credit card input helper

Parameters:

  • id (String) (defaults to: "")

    credit card input id

  • name (String) (defaults to: "")

    credit card input name

  • value (String) (defaults to: "")

    credit card input value

  • label (String) (defaults to: "")

    credit card label

  • required (Boolean) (defaults to: false)

    if required or not

  • placeholder (String) (defaults to: "")

    credit card input placeholder text

  • mask (String) (defaults to: "")

    credit card input mask

  • maxlength (String) (defaults to: "16")

    nuber input max length

Returns:

  • (String)

    compiled html of credit card input



631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
# 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") ⇒ String

CVC input helper

Parameters:

  • id (String) (defaults to: "")

    cvc input id

  • name (String) (defaults to: "")

    cvc input name

  • value (String) (defaults to: "")

    cvc input value

  • lable (String)

    cvc label

  • required (Boolean) (defaults to: false)

    if required or not

  • placeholder (String) (defaults to: "")

    cvc input placeholder text

  • mask (String) (defaults to: "999999999999999999")

    cvc input mask

  • maxlength (String) (defaults to: "4")

    nuber input max length

Returns:

  • (String)

    compiled html of cvc input



676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
# 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: "") ⇒ String

Date input helper

Parameters:

  • id (String) (defaults to: "")

    date input id

  • name (String) (defaults to: "")

    date input name

  • value (String) (defaults to: "")

    date input value

  • label (String) (defaults to: "")

    date input label

  • required (Boolean) (defaults to: false)

    if required or not

  • placeholder (String) (defaults to: "")

    date input placeholder text

Returns:

  • (String)

    compiled html of date input



856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
# 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: "") ⇒ String

Date-time input helper

Parameters:

  • id (String) (defaults to: "")

    date-time input id

  • name (String) (defaults to: "")

    date-time input name

  • value (String) (defaults to: "")

    date-time input value

  • label (String) (defaults to: "")

    date-time input label

  • required (Boolean) (defaults to: false)

    if required or not

  • placeholder (String) (defaults to: "")

    date-time input placeholder text

Returns:

  • (String)

    compiled html of date-time input



893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
# 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") ⇒ String

EIN input helper

Parameters:

  • id (String) (defaults to: "")

    ein input id

  • name (String) (defaults to: "")

    ein input name

  • value (String) (defaults to: "")

    ein input value

  • label (String) (defaults to: "")

    ein input label

  • required (Boolean) (defaults to: false)

    if required or not

  • placeholder (String) (defaults to: "")

    ein input placeholder text

  • mask (String) (defaults to: "99-9999999")

    ein input mask

  • maxlength (String) (defaults to: "10")

    nuber input max length

Returns:

  • (String)

    compiled html of ein input



495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
# 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: "") ⇒ String

Email input helper

Parameters:

  • id (String) (defaults to: "")

    email input id

  • name (String) (defaults to: "")

    email input name

  • value (String) (defaults to: "")

    email input value

  • label (String) (defaults to: "")

    email input label

  • required (Boolean) (defaults to: false)

    if required or not

  • placeholder (String) (defaults to: "")

    email input placeholder text

Returns:

  • (String)

    compiled html of email input



718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
# 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_monthObject

Month Drop down



1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
# 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_yearObject

Year Drop down (expiry)



1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
# 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: "") ⇒ String

File input helper

Parameters:

  • id (String) (defaults to: "")

    file input id

  • name (String) (defaults to: "")

    file input name

  • value (String) (defaults to: "")

    file input value

  • label (String) (defaults to: "")

    file input label

  • required (Boolean) (defaults to: false)

    if required or not

  • placeholder (String) (defaults to: "")

    file input placeholder text

  • css (String) (defaults to: "")

    file input css

Returns:

  • (String)

    compiled html of file input



788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
# 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: "") ⇒ String

Hidden input helper

Parameters:

  • id (String) (defaults to: "")

    hidden input id

  • name (String) (defaults to: "")

    hidden input name

  • value (String) (defaults to: "")

    hidden input value

Returns:

  • (String)

    compiled hidden input html



142
143
144
145
146
147
148
# 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) ⇒ String

Summernote

Parameters:

  • id (String) (defaults to: "")

    summernote id

  • name (String) (defaults to: "")

    summernote name

  • value (String) (defaults to: "")

    summernote value

  • label (String) (defaults to: "")

    summernote label

  • required (Boolean) (defaults to: false)

    if required or not

Returns:

  • (String)

    compiled html of summernote



1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
# 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: "") ⇒ String

Image Upload

Parameters:

  • id (String) (defaults to: "input1")

    file input id

  • name (String) (defaults to: "input1")

    file input name

  • value (String) (defaults to: "")

    file input value

  • label (String) (defaults to: "Input1")

    file input label

  • required (Boolean) (defaults to: false)

    if required or not

  • placeholder (String)

    file input placeholder text

  • css (String)

    file input css

Returns:

  • (String)

    compiled html of file input



822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
# 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: "") ⇒ String

Text input helper

Parameters:

  • id (String) (defaults to: "")

    input element id

  • name (String) (defaults to: "")

    input element name

  • value (String) (defaults to: "")

    input element value

  • label (String) (defaults to: "")

    input element label

  • required (Boolean) (defaults to: false)

    if input element is required

  • placeholder (String) (defaults to: "")

    input element placeholder

  • mask (String) (defaults to: "")

    input element mask

  • maxlength (String) (defaults to: "")

    input element max length

Returns:

  • (String)

    compiled input element



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# 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: "") ⇒ String

Money input helper

Parameters:

  • id (String) (defaults to: "")

    the money input id

  • name (String) (defaults to: "")

    the money input name

  • label (String) (defaults to: "")

    the money input label

  • required (Boolean) (defaults to: false)

    if money input is required or not

  • placeholder (String) (defaults to: "")

    the moeny input placeholder

  • mask (String) (defaults to: "")

    the money input mask

  • maxlength (String) (defaults to: "")

    max length of the input

Returns:

  • (String)

    compiled money input html



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# 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: "") ⇒ String

Number input helper

Parameters:

  • id (String) (defaults to: "")

    number input id

  • name (String) (defaults to: "")

    number input name

  • value (String) (defaults to: "")

    number input value

  • label (String) (defaults to: "")

    number input label

  • required (Boolean) (defaults to: false)

    if required or not

  • placeholder (String) (defaults to: "")

    number input placeholder text

  • mask (String) (defaults to: "")

    number input mask

  • maxlength (String) (defaults to: "")

    nuber input max length

Returns:

  • (String)

    compiled html of number input



360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# 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: "") ⇒ String

Password input helper

Parameters:

  • id (String) (defaults to: "")

    password input id

  • name (String) (defaults to: "")

    password input name

  • value (String) (defaults to: "")

    password input value

  • label (String) (defaults to: "")

    password input label

  • required (Boolean) (defaults to: false)

    if required or not

  • placeholder (String) (defaults to: "")

    password input placeholder text

Returns:

  • (String)

    compiled html of password input



968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
# 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: "") ⇒ Object

Percentage input helper

Parameters:

  • id (String) (defaults to: "")

    percentage input id

  • name (String) (defaults to: "")

    percentage input name

  • value (String) (defaults to: "")

    percentage input value

  • label (String) (defaults to: "")

    percentage input label

  • required (Boolean) (defaults to: false)

    if percentage input is required

  • placeholder (String) (defaults to: "")

    percentage input placeholder

  • mask (String) (defaults to: "")

    percentage input mask

  • maxlength (String) (defaults to: "")

    percentage input maxlength



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# 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") ⇒ String

Phone input helper

Parameters:

  • id (String) (defaults to: "")

    phone input id

  • name (String) (defaults to: "")

    phone input name

  • value (String) (defaults to: "")

    phone input value

  • label (String) (defaults to: "")

    phone input label

  • required (Boolean) (defaults to: false)

    if required or not

  • placeholder (String) (defaults to: "")

    phone input placeholder text

  • mask (String) (defaults to: "(999) 999-9999 x99999")

    phone input mask

  • maxlength (String) (defaults to: "22")

    nuber input max length

Returns:

  • (String)

    compiled html of phone input



407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
# 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) ⇒ String

Radio button view helper

Parameters:

  • id (String) (defaults to: "")

    the radio id

  • name (String) (defaults to: "")

    the name attribute of the radio

  • value (String) (defaults to: "1")

    the radio value

  • label (String) (defaults to: "")

    the label text of the radio

  • checked (Boolean) (defaults to: false)

    if the radio is checked

  • align (String) (defaults to: false)

    if the check box aligned ‘left’ or ‘right’

  • inline (Boolean) (defaults to: false)

    if the radio is inline or not

  • form_group (Boolean) (defaults to: true)

    if the radio is of form group

Returns:

  • (String)

    the compiled radio



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# 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) ⇒ String

Select Dropdown

Parameters:

  • id (String) (defaults to: "")

    id of the select

  • name (String) (defaults to: "")

    name of the select

  • value (String) (defaults to: "")

    value of the select

  • name_col (String) (defaults to: "name")

    name col of the select

  • value_col (String) (defaults to: "id")

    vale col of the select

  • label (String) (defaults to: "")

    label of the select

  • css (String) (defaults to: "selectpicker")

    css of the select

  • menu_style (String) (defaults to: "dropdown-blue")

    menu syle of the select

  • style (String) (defaults to: "btn-default btn-block")

    style classes of the select

  • option_data (String) (defaults to: "")

    option data

  • option_name (String) (defaults to: "name")

    option name

  • option_value (String) (defaults to: "id")

    option value

  • selected_value (String) (defaults to: "")

    selected value of the select

  • title (String) (defaults to: "")

    title of the select

  • multple (Boolean)

    if multiple selection is enabled

Returns:

  • (String)

    compiled select drop down



1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
# 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: "") ⇒ Object

Sq Ft input helper

Parameters:

  • id (String) (defaults to: "")

    percentage input id

  • name (String) (defaults to: "")

    percentage input name

  • value (String) (defaults to: "")

    percentage input value

  • label (String) (defaults to: "")

    percentage input label

  • required (Boolean) (defaults to: false)

    if percentage input is required

  • placeholder (String) (defaults to: "")

    percentage input placeholder

  • mask (String) (defaults to: "")

    percentage input mask

  • maxlength (String) (defaults to: "")

    percentage input maxlength



309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# 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") ⇒ String

SSN input helper

Parameters:

  • id (String) (defaults to: "")

    ssn input id

  • name (String) (defaults to: "")

    ssn input name

  • value (String) (defaults to: "")

    ssn input value

  • label (String) (defaults to: "")

    ssn input label

  • required (Boolean) (defaults to: false)

    if required or not

  • placeholder (String) (defaults to: "")

    ssn input placeholder text

  • mask (String) (defaults to: "999-99-9999")

    ssn input mask

  • maxlength (String)

    nuber input max length

Returns:

  • (String)

    compiled html of ssn input



453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
# 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") ⇒ String

State input helper

Parameters:

  • id (String) (defaults to: "")

    state input id

  • name (String) (defaults to: "")

    state input name

  • value (String) (defaults to: "")

    state input value

  • label (String) (defaults to: "")

    state input label

  • required (Boolean) (defaults to: false)

    if required or not

  • placeholder (String) (defaults to: "")

    state input placeholder text

  • mask (String) (defaults to: "aa")

    state input mask

  • maxlength (String) (defaults to: "2")

    nuber input max length

Returns:

  • (String)

    compiled html of state input



585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
# 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") ⇒ String

Submit Helper

Parameters:

  • label (String) (defaults to: "Submit")

    submit button label

  • css (String) (defaults to: "btn-primary")

    submit button css

  • icon (String) (defaults to: "")

    submit button icon

  • size (String) (defaults to: "")

    submit button size

  • wrapper_css (String) (defaults to: "pull-right")

    submit button wrapper css

Returns:

  • (String)

    compiled html of submit button



1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
# 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: "") ⇒ String

Rating Radios

Parameters:

  • id (String) (defaults to: "")

    id of the survey radio

  • name (String) (defaults to: "")

    name of the survey radio

Returns:

  • (String)

    compiled html of the survey radio



1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
# 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) ⇒ String

Switch

Parameters:

  • id (String) (defaults to: "")

    summernote id

  • name (String) (defaults to: "")

    summernote name

  • value (String) (defaults to: "")

    summernote value

  • label (String) (defaults to: "")

    summernote label

  • checked (Boolen) (defaults to: false)

    if checked or not

Returns:

  • (String)

    compiled html of summernote



1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
# 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: "") ⇒ String

Tags

Parameters:

  • id (String) (defaults to: "")

    tags id

  • name (String) (defaults to: "")

    tags name

  • value (String) (defaults to: "")

    tags value

  • label (String) (defaults to: "")

    tags label

  • required (Boolean) (defaults to: false)

    if required or not

  • placeholder (String) (defaults to: "")

    tags placeholder text

Returns:

  • (String)

    compiled html of tags



1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
# 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: "") ⇒ String

Text Area Helper

Parameters:

  • id (String) (defaults to: "")

    textarea id

  • name (String) (defaults to: "")

    textarea name

  • value (String) (defaults to: "")

    textarea value

  • placeholder (String) (defaults to: "")

    textarea placeholder text

  • label (String) (defaults to: "")

    textarea label

  • required (Boolean) (defaults to: false)

    if required or not

  • maxlength (String) (defaults to: "")

    textarea max length

Returns:

  • (String)

    compiled html of textarea



1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
# 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: "") ⇒ String

Time input helper

Parameters:

  • id (String) (defaults to: "")

    time input id

  • name (String) (defaults to: "")

    time input name

  • value (String) (defaults to: "")

    time input value

  • label (String) (defaults to: "")

    time input label

  • required (Boolean) (defaults to: false)

    if required or not

  • placeholder (String) (defaults to: "")

    time input placeholder text

Returns:

  • (String)

    compiled html of time input



930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
# 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: "") ⇒ String

Typeahead

Parameters:

  • id (String) (defaults to: "")

    typeahead id

  • name (String) (defaults to: "")

    typeahead name

  • value (String) (defaults to: "")

    typeahead value

  • label (String) (defaults to: "")

    typeahead label

  • required (Boolean) (defaults to: false)

    if required or not

  • placeholder (String) (defaults to: "")

    typeahead placeholder text

  • css (String) (defaults to: "")

    typeahead css

Returns:

  • (String)

    compiled html of typeahead



1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
# 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: "") ⇒ String

URL input helper

Parameters:

  • id (String) (defaults to: "")

    url input id

  • name (String) (defaults to: "")

    url input name

  • value (String) (defaults to: "")

    url input value

  • label (String) (defaults to: "")

    url input label

  • required (Boolean) (defaults to: false)

    if required or not

  • placeholder (String) (defaults to: "")

    url input placeholder text

Returns:

  • (String)

    compiled html of url input



753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
# 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_yearObject

Year Drop down



1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
# 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") ⇒ String

Zip input helper

Parameters:

  • id (String) (defaults to: "")

    zip input id

  • name (String) (defaults to: "")

    zip input name

  • value (String) (defaults to: "")

    zip input value

  • label (String) (defaults to: "")

    zip input label

  • required (Boolean) (defaults to: false)

    if required or not

  • placeholder (String) (defaults to: "")

    zip input placeholder text

  • mask (String) (defaults to: "99999")

    zip input mask

  • maxlength (String) (defaults to: "5")

    nuber input max length

Returns:

  • (String)

    compiled html of zip input



540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
# 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