SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/Helpers/RefineWidgetDatepicker.php

  1. <?php
  2. /*
  3.  * Copyright (C) 2017 Karmabunny Pty Ltd.
  4.  *
  5.  * This file is a part of SproutCMS.
  6.  *
  7.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation, either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * For more information, visit <http://getsproutcms.com>.
  12.  */
  13.  
  14. namespace Sprout\Helpers;
  15.  
  16. /**
  17.  * A datepicker widget for the refine bar
  18.  */
  19. class RefineWidgetDatepicker extends RefineWidget
  20. {
  21. private $options;
  22.  
  23.  
  24. /**
  25.   * @param string $name The field name, e.g. 'name', '_some_foreign_column'
  26.   * @param string $label The label to display on the form, e.g. 'Name'
  27.   * @param array $options Options for the autocomplete field; see $options of {@see Fb::autocomplete}
  28.   *
  29.   */
  30. public function __construct($name, $label, $options)
  31. {
  32. parent::__construct($name, $label);
  33. $this->options = $options;
  34. }
  35.  
  36.  
  37. /**
  38.   * Draws the widget.
  39.   * @return string The HTML for the widget.
  40.   */
  41. public function render()
  42. {
  43. Form::setFieldValue($this->name, $this->getValue());
  44.  
  45. Form::nextFieldDetails($this->label, false);
  46. return Form::datepicker($this->name, ['-wrapper-class' => 'white small'], $this->options);
  47. }
  48.  
  49. }
  50.