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) ⇒ String
View helper to generate check box.
-
#x_checkbox_string(id: "", name: "", value: "", label: "", checked: false, switch: false, align: false, inline: false, form_group: true, required: false) ⇒ String
Check box helper.
-
#x_credit_card(id: "", name: "", value: "", label: "", required: false, placeholder: "", maxlength: "16", mask: "") ⇒ String
Credit card input helper.
-
#x_cvc(id: "", name: "", value: "", label: "", required: false, placeholder: "", maxlength: "4", mask: "999999999999999999") ⇒ String
CVC input helper.
-
#x_date(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ String
Date input helper.
-
#x_datetime(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ String
Date-time input helper.
-
#x_email(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ String
Email input helper.
-
#x_exp_month ⇒ Object
Month Drop down.
-
#x_exp_year ⇒ Object
Year Drop down (expiry).
-
#x_file(id: "", name: "", value: "", label: "", required: false, placeholder: "", css: "") ⇒ String
File input helper.
-
#x_hidden(id: "", name: "", value: "") ⇒ String
Hidden input helper.
-
#x_html(id: "", name: "", value: "", label: "", help: "", required: false) ⇒ String
Summernote.
-
#x_image_upload(id: "input1", name: "input1", value: "", label: "Input1", required: false, size: "1M", height: "", default: "") ⇒ String
Image Upload.
-
#x_input(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "") ⇒ String
Text input helper.
-
#x_money(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "") ⇒ String
Money input helper.
-
#x_number(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "") ⇒ String
Number input helper.
-
#x_password(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ String
Password input helper.
-
#x_percentage(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "") ⇒ Object
Percentage input helper.
-
#x_phone(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "(999) 999-9999", maxlength: "12") ⇒ String
Phone input helper.
-
#x_radio(id: "", name: "", value: "", label: "", checked: false, align: false, inline: false, form_group: true) ⇒ String
Radio button view 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: "", title: "", multiple: false) ⇒ String
Select Dropdown.
-
#x_submit(label: "Submit", css: "btn-primary", icon: "", size: "", wrapper_css: "pull-right") ⇒ String
Submit Helper.
-
#x_survey_radio(id: "", name: "") ⇒ String
Rating Radios.
-
#x_switch(id: "", name: "", value: "", label: "", checked: false) ⇒ String
Switch.
-
#x_tags(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ String
Tags.
-
#x_textarea(id: "", name: "", value: "", label: "", placeholder: "", required: false, maxlength: "") ⇒ String
Text Area Helper.
-
#x_time(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ String
Time input helper.
-
#x_typeahead(id: "", name: "", value: "", label: "", required: false, placeholder: "", css: "") ⇒ String
Typeahead.
-
#x_url(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ String
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) ⇒ String
View helper to generate check box
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/platformx/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 = "\#{form_group_start}\n<div class=\"checkbox \#{switchery_div}\">\n<label class=\"\#{align_class} \#{inline_class}\">\n<input type=\"hidden\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"0\">\n<input type=\"checkbox\" class=\"\#{switchery_input}\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"1\" \#{checked_output} data-toggle=\"checkbox\" \#{required_output}/>\n\#{label} </label>\n</div>\n\#{form_group_end}\n" 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
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/platformx/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 = "\#{form_group_start}\n<div class=\"checkbox \#{switchery_div}\">\n<label class=\"\#{align_class} \#{inline_class}\">\n<input type=\"checkbox\" class=\"\#{switchery_input}\" id=\"\#{id}\" name=\"\#{name}\" value=\"\#{value}\" \#{checked_output} data-toggle=\"checkbox\" \#{required_output}/>\n\#{label} </label>\n</div>\n\#{form_group_end}\n" return cb end |
#x_credit_card(id: "", name: "", value: "", label: "", required: false, placeholder: "", maxlength: "16", mask: "") ⇒ String
Credit card input helper
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
# File 'lib/platformx/form.rb', line 394 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 = "<div class=\"form-group\">\n\#{label}\n<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} />\n</div>\n" return tb end |
#x_cvc(id: "", name: "", value: "", label: "", required: false, placeholder: "", maxlength: "4", mask: "999999999999999999") ⇒ String
CVC input helper
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 |
# File 'lib/platformx/form.rb', line 439 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 = "<div class=\"form-group\">\n\#{label}\#{required_output}\n<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} />\n</div>\n" return tb end |
#x_date(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ String
Date input helper
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
# File 'lib/platformx/form.rb', line 619 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 = "<div class=\"form-group\">\n\#{label}\#{required_output}\n<div class=\"input-group\">\n<span class=\"input-group-addon\"><i class=\"fa fa-calendar\"></i></span>\n<input type=\"text\" class=\"form-control datepicker\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"\#{value}\" \#{required_tag} placeholder=\"\#{placeholder}\" />\n</div>\n</div>\n" return tb end |
#x_datetime(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ String
Date-time input helper
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
# File 'lib/platformx/form.rb', line 656 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 = "<div class=\"form-group\">\n\#{label}\#{required_output}\n<div class=\"input-group\">\n<span class=\"input-group-addon\"><i class=\"fa fa-calendar\"></i></span>\n<input type=\"text\" class=\"form-control datetimepicker\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"\#{value}\" \#{required_tag} placeholder=\"\#{placeholder}\" />\n</div>\n</div>\n" return tb end |
#x_email(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ String
Email input helper
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
# File 'lib/platformx/form.rb', line 481 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 = "<div class=\"form-group\">\n\#{label}\#{required_output}\n<input type=\"email\" class=\"form-control\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"\#{value}\" \#{required_tag} data-parsley-type=\"email\" placeholder=\"\#{placeholder}\" />\n</div>\n" return tb end |
#x_exp_month ⇒ Object
Month Drop down
904 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 |
# File 'lib/platformx/form.rb', line 904 def x_exp_month current_year = Time.now.year begining_year = Time.now.year - 6 year_dd = "<div class=\"col-md-6\">\n<div class=\"form-group\">\n<label>Expiration Month</label>\n<select id=\"exp_mo\" name=\"post[exp_mo]\" class=\"form-control\" data-stripe=\"exp-month\">\n<option value=\"01\">01</option>\n<option value=\"02\">02</option>\n<option value=\"03\">03</option>\n<option value=\"04\">04</option>\n<option value=\"05\">05</option>\n<option value=\"06\">06</option>\n<option value=\"07\">07</option>\n<option value=\"08\">08</option>\n<option value=\"09\">09</option>\n<option value=\"10\">10</option>\n<option value=\"11\">11</option>\n<option value=\"12\">12</option>\n</select>\n</div>\n</div>\n" end |
#x_exp_year ⇒ Object
Year Drop down (expiry)
880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 |
# File 'lib/platformx/form.rb', line 880 def x_exp_year current_year = Time.now.year begining_year = Time.now.year + 6 year_dd = "<div class=\"col-md-6\">\n<div class=\"form-group\">\n<label>Expiration Year</label>\n<select id=\"exp_year\" name=\"post[exp_year]\" class=\"form-control\" data-stripe=\"exp-year\">\n<option value=\"\#{(current_year)}\">\#{current_year}</option>\n<option value=\"\#{(current_year + 1)}\">\#{current_year + 1}</option>\n<option value=\"\#{(current_year + 2)}\">\#{current_year + 2}</option>\n<option value=\"\#{(current_year + 3)}\">\#{current_year + 3}</option>\n<option value=\"\#{(current_year + 4)}\">\#{current_year + 4}</option>\n<option value=\"\#{(current_year + 5)}\">\#{current_year + 5}</option>\n<option value=\"\#{(current_year + 6)}\">\#{current_year + 6}</option>\n<option value=\"\#{(current_year + 7)}\">\#{current_year + 7}</option>\n</select>\n</div>\n</div>\n" end |
#x_file(id: "", name: "", value: "", label: "", required: false, placeholder: "", css: "") ⇒ String
File input helper
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 |
# File 'lib/platformx/form.rb', line 551 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 = "<div class=\"form-group\">\n\#{label}\#{required_output}\n<input type=\"file\" class=\"form-control file \#{css}\" id=\"\#{id}\" name=\"filename\" value=\"\#{value}\" \#{required_tag} placeholder=\"\#{placeholder}\" />\n</div>\n" return tb end |
#x_hidden(id: "", name: "", value: "") ⇒ String
Hidden input helper
139 140 141 142 143 144 145 |
# File 'lib/platformx/form.rb', line 139 def x_hidden(id: "", name: "", value: "") hi = "<input type=\"hidden\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"\#{value}\"/>\n" return hi end |
#x_html(id: "", name: "", value: "", label: "", help: "", required: false) ⇒ String
Summernote
833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 |
# File 'lib/platformx/form.rb', line 833 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 = "<div class=\"form-group\">\n\#{label}\n<textarea name=\"post[\#{name}]\" id=\"\#{id}\" rows=\"4\" class=\"form-control summernote\">\#{value}</textarea>\n</div>\n" return ta end |
#x_image_upload(id: "input1", name: "input1", value: "", label: "Input1", required: false, size: "1M", height: "", default: "") ⇒ String
Image Upload
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 |
# File 'lib/platformx/form.rb', line 585 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 = "<div class=\"form-group\">\n<label>\#{label}</label>\n<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}/>\n</div>\n" return tb end |
#x_input(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "") ⇒ String
Text input helper
158 159 160 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 |
# File 'lib/platformx/form.rb', line 158 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 = "<div class=\"form-group\">\n\#{label}\#{required_output}\n<input type=\"text\" class=\"form-control\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"\#{value}\" placeholder=\"\#{placeholder}\" \#{required_tag} \#{mask} \#{maxlength} />\n</div>\n" return tb end |
#x_money(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "") ⇒ String
Money input helper
204 205 206 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 |
# File 'lib/platformx/form.rb', line 204 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 tb = "<div class=\"form-group\">\n<div class=\"input-group\">\n<span class=\"input-group-addon\">$</span>\n\#{label}\#{required_output}\n<input type=\"text\" class=\"form-control\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"\#{value}\" placeholder=\"\#{placeholder}\" data-parsley-type=\"number\" \#{required_tag} \#{mask} \#{maxlength} />\n</div>\n</div>\n" return tb end |
#x_number(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "") ⇒ String
Number input helper
301 302 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 |
# File 'lib/platformx/form.rb', line 301 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 = "<div class=\"form-group\">\n\#{label}\n<input type=\"text\" class=\"form-control\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"\#{value}\" \#{required_tag} placeholder=\"\#{placeholder}\" data-parsley-type=\"number\" \#{mask} \#{maxlength}/>\n</div>\n" return tb end |
#x_password(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ String
Password input helper
731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 |
# File 'lib/platformx/form.rb', line 731 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 = "<div class=\"form-group\">\n\#{label}\#{required_output}\n<input type=\"password\" class=\"form-control\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"\#{value}\" \#{required_tag} data-parsley-length=\"[6, 34]\" placeholder=\"\#{placeholder}\" />\n</div>\n" return tb end |
#x_percentage(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "", maxlength: "") ⇒ Object
Percentage input helper
252 253 254 255 256 257 258 259 260 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 |
# File 'lib/platformx/form.rb', line 252 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 = "<div class=\"form-group\">\n<div class=\"input-group\">\n<span class=\"input-group-addon\">%</span>\n\#{label}\#{required_output}\n<input type=\"text\" class=\"form-control\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"\#{value}\" placeholder=\"\#{placeholder}\" data-parsley-type=\"number\" \#{required_tag} \#{mask} \#{maxlength} />\n</div>\n</div>\n" return tb end |
#x_phone(id: "", name: "", value: "", label: "", required: false, placeholder: "", mask: "(999) 999-9999", maxlength: "12") ⇒ String
Phone input helper
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
# File 'lib/platformx/form.rb', line 348 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 = "<div class=\"form-group\">\n\#{label}\n<input type=\"text\" class=\"form-control\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"\#{value}\" \#{required_tag} placeholder=\"\#{placeholder}\" \#{mask} \#{maxlength} />\n</div>\n" return tb end |
#x_radio(id: "", name: "", value: "", label: "", checked: false, align: false, inline: false, form_group: true) ⇒ String
Radio button view helper
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 |
# File 'lib/platformx/form.rb', line 106 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 = "\#{form_group_start}\n<div class=\"radio\">\n<label class=\"\#{align_class} \#{inline_class}\">\n<input type=\"hidden\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"0\">\n<input type=\"radio\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"1\" \#{checked_output} data-toggle=\"radio\"/>\n\#{label} </label>\n</div>\n\#{form_group_end}\n" 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: "", title: "", multiple: false) ⇒ String
Select Dropdown
1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 |
# File 'lib/platformx/form.rb', line 1080 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: "", title: "", multiple: false) = "" show_multiple = "" if multiple == true show_multiple = "Multiple" end multiple_name = "" if multiple == true multiple_name = "[]" end 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 << "<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 = "<div class=\"form-group\">\n<label>\#{label}</label>\n<select name=\"post[\#{name}]\#{multiple_name}\" class=\"\#{css}\" data-title=\"\#{title}\" title=\"\#{title}\" data-style=\"\#{style}\" data-menu-style=\"\#{menu_style}\" \#{show_multiple}\">\n\#{options_html}\n</select>\n</div>\n" return select end |
#x_submit(label: "Submit", css: "btn-primary", icon: "", size: "", wrapper_css: "pull-right") ⇒ String
Submit Helper
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 |
# File 'lib/platformx/form.rb', line 764 def x_submit(label: "Submit", css: "btn-primary", icon: "", size: "", wrapper_css: "pull-right") if icon != "" icon = "<i class='fa #{icon}'></i> " end submit = "<div class=\"form-group form-actions \#{wrapper_css}\">\n<button type=\"submit\" class=\"btn \#{css} \#{size}\">\#{icon}\#{label}</button>\n</div>\n<div class=\"clearfix\"></div>\n" return submit end |
#x_survey_radio(id: "", name: "") ⇒ String
Rating Radios
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 |
# File 'lib/platformx/form.rb', line 1035 def x_survey_radio(id: "", name: "") tb = "<label class=\"radio radio-inline\">\n<input type=\"radio\" id=\"\#{id}\" name=\"\#{name}\" data-toggle=\"radio\" value=\"1\">\n</label>\n<label class=\"radio radio-inline\">\n<input type=\"radio\" id=\"\#{id}\" name=\"\#{name}\" data-toggle=\"radio\" value=\"2\">\n</label>\n<label class=\"radio radio-inline\">\n<input type=\"radio\" id=\"\#{id}\" name=\"\#{name}\" data-toggle=\"radio\" value=\"3\">\n</label>\n<label class=\"radio radio-inline\">\n<input type=\"radio\" id=\"\#{id}\" name=\"\#{name}\" data-toggle=\"radio\" value=\"4\">\n</label>\n<label class=\"radio radio-inline\">\n<input type=\"radio\" id=\"\#{id}\" name=\"\#{name}\" data-toggle=\"radio\" value=\"5\">\n</label>\n<label class=\"radio radio-inline\">\n<input type=\"radio\" id=\"\#{id}\" name=\"\#{name}\" data-toggle=\"radio\" value=\"6\">\n</label>\n<label class=\"radio radio-inline\">\n<input type=\"radio\" id=\"\#{id}\" name=\"\#{name}\" data-toggle=\"radio\" value=\"7\">\n</label>\n" return tb end |
#x_switch(id: "", name: "", value: "", label: "", checked: false) ⇒ String
Switch
938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 |
# File 'lib/platformx/form.rb', line 938 def x_switch(id: "", name: "", value: "", label: "", checked: false) checked_output = "" if checked == true then checked_output='checked="checked"' end cb = "<div class=\"form-group\">\n<label>\#{label}</label><br>\n<div class=\"switch\"\ndata-on-label=\"<i class='fa fa-check'></i>\"\ndata-off-label=\"<i class='fa fa-times'></i>\">\n<input type=\"hidden\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"0\">\n<input type=\"checkbox\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"1\" \#{checked_output}/>\n</div>\n</div>\n" return cb end |
#x_tags(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ String
Tags
966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 |
# File 'lib/platformx/form.rb', line 966 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 = "<div class=\"form-group\">\n\#{label}\#{required_output}\n<input type=\"text\" class=\"form-control tagsinput typeahead tag-azure tag-fill\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"\#{value}\" placeholder=\"\#{placeholder}\" \#{required_tag}/>\n</div>\n" return tb end |
#x_textarea(id: "", name: "", value: "", label: "", placeholder: "", required: false, maxlength: "") ⇒ String
Text Area Helper
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 |
# File 'lib/platformx/form.rb', line 791 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 = "<div class=\"form-group\">\n\#{label}\#{required_output}\n<textarea name=\"post[\#{name}]\" id=\"\#{id}\" rows=\"4\" class=\"form-control\" placeholder=\"\#{placeholder}\" \#{maxlength}>\#{value}</textarea>\n</div>\n" return ta end |
#x_time(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ String
Time input helper
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 |
# File 'lib/platformx/form.rb', line 693 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 = "<div class=\"form-group\">\n\#{label}\#{required_output}\n<div class=\"input-group\">\n<span class=\"input-group-addon\"><i class=\"fa fa fa-clock-o\"></i></span>\n<input type=\"text\" class=\"form-control timepicker\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"\#{value}\" \#{required_tag} placeholder=\"\#{placeholder}\" />\n</div>\n</div>\n" return tb end |
#x_typeahead(id: "", name: "", value: "", label: "", required: false, placeholder: "", css: "") ⇒ String
Typeahead
1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 |
# File 'lib/platformx/form.rb', line 1003 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 = "<div class=\"form-group\">\n\#{label}\#{required_output}\n<input type=\"text\" class=\"form-control typeahead \#{css}\" autocomplete=\"off\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"\#{value}\" placeholder=\"\#{placeholder}\" \#{required_tag}/>\n</div>\n" return tb end |
#x_url(id: "", name: "", value: "", label: "", required: false, placeholder: "") ⇒ String
URL input helper
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
# File 'lib/platformx/form.rb', line 516 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 = "<div class=\"form-group\">\n\#{label}\#{required_output}\n<input type=\"url\" class=\"form-control\" id=\"\#{id}\" name=\"post[\#{name}]\" value=\"\#{value}\" \#{required_tag} data-parsley-type=\"url\" placeholder=\"\#{placeholder}\" />\n</div>\n" return tb end |
#x_year ⇒ Object
Year Drop down
861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 |
# File 'lib/platformx/form.rb', line 861 def x_year current_year = Time.now.year year_dd = "<select id=\"selected_year\" name=\"selected_year\" class=\"selectpicker\" data-style=\"btn-primary btn\" data-width=\"auto\">\n<option selected=\"selected\" value=\"\#{current_year}\">\#{current_year}</option>\n<option value=\"\#{current_year - 1}\">\#{current_year - 1}</option>\n<option value=\"\#{current_year - 2}\">\#{current_year - 2}</option>\n<option value=\"\#{current_year - 3}\">\#{current_year - 3}</option>\n<option value=\"\#{current_year - 4}\">\#{current_year - 4}</option>\n<option value=\"\#{current_year - 5}\">\#{current_year - 5}</option>\n<option value=\"\#{current_year - 6}\">\#{current_year - 6}</option>\n<option value=\"\#{current_year - 7}\">\#{current_year - 7}</option>\n</select>\n" end |