Module: Platformx::FormHelpers
- Defined in:
- lib/platformx/form.rb
Instance Method Summary collapse
- #x_checkbox(id: "", name: "", value: "", label: "", checked: false, switch: false, align: false, inline: false, form_group: true, required: false) ⇒ Object
-
#x_checkbox_string(id: "", name: "", value: "", label: "", checked: false, switch: false, align: false, inline: false, form_group: true, required: false) ⇒ Object
Checkbox helper.
-
#x_credit_card(id: "", name: "", value: "", label: "", required: false, placeholder: "", maxlength: "16", mask: "") ⇒ Object
Number input helper.
-
#x_cvc(id: "", name: "", value: "", label: "", required: false, placeholder: "", maxlength: "4", mask: "999999999999999999") ⇒ Object
Number input helper.
-
#x_date(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ Object
Date input helper.
-
#x_datetime(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ Object
Datetime input helper.
- #x_email(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ Object
-
#x_exp_month ⇒ Object
Month Drop down.
-
#x_exp_year ⇒ Object
Year Drop down.
-
#x_file(id: "", name: "", value: "", label: "", required: false, placeholder: "", css: "") ⇒ Object
File input helper.
-
#x_hidden(id: "", name: "", value: "") ⇒ Object
Hidden input helper.
-
#x_html(id: "", name: "", value: "", label: "", help: "", required: false) ⇒ Object
Summernote.
-
#x_image_upload(id: "input1", name: "input1", value: "", label: "Input1", required: false, size: "1M", height: "", default: "") ⇒ Object
Image Upload.
-
#x_input(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "") ⇒ Object
Text input helper.
-
#x_number(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "") ⇒ Object
Number input helper.
-
#x_password(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ Object
Password input helper.
-
#x_phone(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "(999) 999-9999", maxlength: "12") ⇒ Object
Phone input helper.
-
#x_radio(id: "", name: "", value: "", label: "", checked: false, align: false, inline: false, form_group: true) ⇒ Object
Radio helper.
-
#x_select(id: "", name: "", value: "", name_col: "name", value_col: "id", label: "", css: "", menu_style: "dropdown-blue", style: "btn-default btn-block", option_data: "", option_name: "name", option_value: "id", selected_value: "") ⇒ Object
Select Dropdown.
-
#x_submit(label: "Submit", css: "btn-primary", icon: "", size: "", wrapper_css: "pull-right") ⇒ Object
Submit Helper.
-
#x_survey_radio(id: "", name: "") ⇒ Object
Rating Radios.
-
#x_switch(id: "", name: "", value: "", label: "", checked: false) ⇒ Object
Switch.
-
#x_tags(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ Object
Tags.
-
#x_textarea(id: "", name: "", value: "", label: "", placeholder: "", required: false, maxlength: "") ⇒ Object
Text Area Helper.
-
#x_time(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ Object
Time input helper.
-
#x_typeahead(id: "", name: "", value: "", label: "", required: false, placeholder: "", css: "") ⇒ Object
Typeahead.
-
#x_url(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ Object
URL input helper.
-
#x_year ⇒ Object
Year Drop down.
Instance Method Details
#x_checkbox(id: "", name: "", value: "", label: "", checked: false, switch: false, align: false, inline: false, form_group: true, required: false) ⇒ Object
13 14 15 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 |
# File 'lib/platformx/form.rb', line 13 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) ⇒ Object
Checkbox helper
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/platformx/form.rb', line 52 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: "") ⇒ Object
Number input helper
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 |
# File 'lib/platformx/form.rb', line 263 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") ⇒ Object
Number input helper
303 304 305 306 307 308 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 |
# File 'lib/platformx/form.rb', line 303 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: "") ⇒ Object
Date input helper
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
# File 'lib/platformx/form.rb', line 466 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: "") ⇒ Object
Datetime input helper
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 |
# File 'lib/platformx/form.rb', line 500 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_email(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ Object
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File 'lib/platformx/form.rb', line 341 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 ⇒ Object
Month Drop down
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 |
# File 'lib/platformx/form.rb', line 749 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 ⇒ Object
Year Drop down
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 |
# File 'lib/platformx/form.rb', line 720 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: "") ⇒ Object
File input helper
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
# File 'lib/platformx/form.rb', line 405 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: "") ⇒ Object
Hidden input helper
124 125 126 127 128 129 130 |
# File 'lib/platformx/form.rb', line 124 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) ⇒ Object
Summernote
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 |
# File 'lib/platformx/form.rb', line 663 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: "") ⇒ Object
Image Upload
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
# File 'lib/platformx/form.rb', line 435 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: "") ⇒ Object
Text input helper
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/platformx/form.rb', line 138 def x_input(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} <input type="text" class="form-control" id="#{id}" name="post[#{name}]" value="#{value}" placeholder="#{placeholder}" #{required_tag} #{mask} #{maxlength} /> </div> EOS return tb end |
#x_number(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "") ⇒ Object
Number input helper
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/platformx/form.rb', line 180 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: "") ⇒ Object
Password input helper
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 |
# File 'lib/platformx/form.rb', line 569 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_phone(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "(999) 999-9999", maxlength: "12") ⇒ Object
Phone input helper
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 251 252 253 254 255 |
# File 'lib/platformx/form.rb', line 222 def x_phone(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "(999) 999-9999", maxlength: "12") 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: "", label: "", checked: false, align: false, inline: false, form_group: true) ⇒ Object
Radio helper
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/platformx/form.rb', line 91 def x_radio(id: "", name: "", value: "", label: "", checked: false, align: false, inline: false, form_group: true) checked_output = "" align_class = "" inline_class = "" form_group_start = "" form_group_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 cb = <<EOS #{form_group_start} <div class="radio"> <label class="#{align_class} #{inline_class}"> <input type="hidden" id="#{id}" name="post[#{name}]" value="0"> <input type="radio" id="#{id}" name="post[#{name}]" value="1" #{checked_output} data-toggle="radio"/> #{label} </label> </div> #{form_group_end} EOS return cb end |
#x_select(id: "", name: "", value: "", name_col: "name", value_col: "id", label: "", css: "", menu_style: "dropdown-blue", style: "btn-default btn-block", option_data: "", option_name: "name", option_value: "id", selected_value: "") ⇒ Object
Select Dropdown
905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 |
# File 'lib/platformx/form.rb', line 905 def x_select(id: "", name: "", value: "",name_col: "name", value_col: "id", label: "", css: "", menu_style: "dropdown-blue", style: "btn-default btn-block", option_data: "", option_name: "name", option_value: "id", selected_value: "") = "" option_data.each do |i| selected = "" if selected_value == i[:id] selected = "selected='selected'" end unless name_col.kind_of?(Array) << "<option value='#{i[value_col.to_sym]}' #{selected}>#{i[name_col.to_sym]}</option>" else label = "" << "<option value='#{i[value_col.to_sym]}' #{selected}>" name_col.each do |n| << "#{i[n.to_sym]} " end << "</option>" end end if option_data.count == 0 || option_data.nil? << "<option value=''>No available selections</option>" end select = <<EOS <div class="form-group"> <label>#{label}</label> <select name="post[#{name}]" class="selectpicker #{css}" data-title="Single Select" data-style="#{style}" data-menu-style="#{}"> #{} </select> </div> EOS return select end |
#x_submit(label: "Submit", css: "btn-primary", icon: "", size: "", wrapper_css: "pull-right") ⇒ Object
Submit Helper
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 |
# File 'lib/platformx/form.rb', line 600 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: "") ⇒ Object
Rating Radios
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 |
# File 'lib/platformx/form.rb', line 872 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) ⇒ Object
Switch
781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 |
# File 'lib/platformx/form.rb', line 781 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: "") ⇒ Object
Tags
806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 |
# File 'lib/platformx/form.rb', line 806 def (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: "") ⇒ Object
Text Area Helper
623 624 625 626 627 628 629 630 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 |
# File 'lib/platformx/form.rb', line 623 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}>#{value}</textarea> </div> EOS return ta end |
#x_time(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ Object
Time input helper
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 |
# File 'lib/platformx/form.rb', line 534 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: "") ⇒ Object
Typeahead
839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 |
# File 'lib/platformx/form.rb', line 839 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: "") ⇒ Object
URL input helper
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
# File 'lib/platformx/form.rb', line 374 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 ⇒ Object
Year Drop down
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 |
# File 'lib/platformx/form.rb', line 696 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 |