SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/views/admin/style_guide/forms.php

  1. <?php
  2. use Sprout\Helpers\Form;
  3. use Sprout\Helpers\Treenode;
  4. ?>
  5.  
  6.  
  7. <?php
  8. $form_attributes = [
  9. 'Grey + regular (default) elements' => [],
  10. 'Grey + small elements' => ['-wrapper-class' => 'small'],
  11. 'Grey + large elements' => ['-wrapper-class' => 'large'],
  12. 'White + regular' => ['-wrapper-class' => 'white'],
  13. 'White + small elements' => ['-wrapper-class' => 'white small'],
  14. 'White + large elements' => ['-wrapper-class' => 'white large'],
  15. 'Disabled' => ['disabled' => 'disabled'],
  16. ];
  17.  
  18.  
  19. $dropdown_tree = new Treenode();
  20. $child = new Treenode(['id' => 10, 'name' => 'A']);
  21. $dropdown_tree->children[] = $child;
  22. $child->parent = $dropdown_tree;
  23.  
  24. foreach ($form_attributes as $label => $attributes) {
  25. echo '<h2>', $label, '</h2>';
  26.  
  27.  
  28. Form::nextFieldDetails('Text', false);
  29. echo Form::text('textz', $attributes);
  30.  
  31. Form::nextFieldDetails('Select', false);
  32. echo Form::dropdown('dropdown', $attributes, [0 => "Lol", 1 => "Rofl", 2 => "Lmao"]);
  33.  
  34. Form::nextFieldDetails('Select tree', false);
  35. echo Form::dropdownTree('dropdown_tree', $attributes, [
  36. 'root' => $dropdown_tree,
  37. 'exclude' => [1, 2, 3],
  38. ]);
  39.  
  40. Form::nextFieldDetails('Number', false);
  41. echo Form::number('number', $attributes);
  42.  
  43. Form::nextFieldDetails('Dollars', false);
  44. echo Form::money('dollars', $attributes);
  45.  
  46. Form::nextFieldDetails('Range', false);
  47. echo Form::range('range', $attributes);
  48.  
  49. Form::nextFieldDetails('Password', false);
  50. echo Form::password('password', $attributes);
  51.  
  52. Form::nextFieldDetails('Upload', false);
  53. echo Form::upload('upload', $attributes);
  54.  
  55. Form::nextFieldDetails('Email', false);
  56. echo Form::email('email', $attributes);
  57.  
  58. Form::nextFieldDetails('Phone', false);
  59. echo Form::phone('phone', $attributes);
  60.  
  61. Form::nextFieldDetails('Multiline', false);
  62. echo Form::multiline('multiline', $attributes + ['rows' => '5']);
  63.  
  64. Form::nextFieldDetails('Multiradio', false);
  65. echo Form::multiradio('multiradio', $attributes, ['box1' => "I'm a checkbox", 'box2' => "Don't judge me"]);
  66.  
  67. Form::nextFieldDetails('Checkbox list', false);
  68. echo Form::checkboxBoolList('checkboxList', $attributes, ['box1' => "I'm a checkbox", 'box2' => "Don't judge me"]);
  69.  
  70. Form::nextFieldDetails('Richtext', false);
  71. echo Form::richtext('richtext', $attributes);
  72.  
  73. Form::nextFieldDetails('More text', false);
  74. echo Form::text('textz', $attributes);
  75.  
  76. Form::nextFieldDetails('Date picker', false);
  77. echo Form::datepicker('datepicker', $attributes);
  78.  
  79. Form::nextFieldDetails('Time picker', false);
  80. echo Form::timepicker('timepicker', $attributes);
  81.  
  82. Form::nextFieldDetails('Date range picker', false);
  83. echo Form::daterangepicker('Depart, Arrive', $attributes);
  84.  
  85. Form::nextFieldDetails('Date/time range picker', false);
  86. echo Form::datetimerangepicker('Depart,Arrive', $attributes);
  87.  
  88. Form::nextFieldDetails('Date/time picker', false);
  89. echo Form::datetimepicker('datetimepicker', $attributes);
  90.  
  91. Form::nextFieldDetails('Simple date range picker', false);
  92. echo Form::simpledaterangepicker('simpledatestart,simpledateend', $attributes);
  93.  
  94. Form::nextFieldDetails('Colour picker', false);
  95. echo Form::colorpicker('colorpicker', $attributes);
  96.  
  97. Form::nextFieldDetails('Total selector', false);
  98. echo Form::totalselector('totalselector', $attributes, [
  99. 'singular' => 'guest',
  100. 'plural' => 'guests',
  101. 'fields' => [
  102. [
  103. 'name' => 'adults',
  104. 'label' => 'Adults',
  105. 'min' => 1,
  106. 'max' => 10
  107. ],
  108. [
  109. 'name' => 'kids',
  110. 'label' => 'Kids',
  111. 'helptext' => '(2-12 yrs)',
  112. ]
  113. ]
  114. ]);
  115.  
  116. Form::nextFieldDetails('Random code field', false);
  117. echo Form::randomCode('randomCode', $attributes);
  118. }
  119. ?>
  120.