SproutCMS

This is the code documentation for the SproutCMS project

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

  1. <?php
  2. use Sprout\Helpers\Enc;
  3. use Sprout\Helpers\Form;
  4. ?>
  5.  
  6.  
  7. <?php
  8. if (!empty($_POST)) {
  9. echo '<h3>$_POST</h3>';
  10. echo '<pre>', Enc::html(print_r($_POST, true)), '</pre>';
  11. Form::setData($_POST);
  12. } else {
  13. Form::setData([
  14. 'conditions' => json_encode([
  15. ['field' => 'age', 'op' => '>=', 'val' => 20],
  16. ['field' => 'age', 'op' => '<=', 'val' => 40],
  17. ['field' => 'name', 'op' => 'begin', 'val' => 'Joe'],
  18. ]),
  19. 'random' => 'Random text',
  20. ]);
  21. }
  22. ?>
  23.  
  24.  
  25. <form action="" method="post">
  26.  
  27. <h3>Form fields</h3>
  28.  
  29. <?php
  30. Form::nextFieldDetails('Example conditions', false);
  31. echo Form::conditionsList('conditions', [], [
  32. 'fields' => [
  33. 'name' => 'Name',
  34. 'age' => 'Age',
  35. 'gender' => 'Gender',
  36. ],
  37. 'url' => 'admin_ajax/style_guide_demo_conditions',
  38. ]);
  39. ?>
  40.  
  41. <?php
  42. Form::nextFieldDetails('Random text field', false);
  43. echo Form::text('random', [], []);
  44. ?>
  45.  
  46. <button type="submit" class="button right">Submit form</button>
  47. </form>