source of /sprout/Helpers/RefineWidgetAutocomplete.php<?php /* * Copyright (C) 2017 Karmabunny Pty Ltd. * * This file is a part of SproutCMS. * * SproutCMS is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Foundation, either * version 2 of the License, or (at your option) any later version. * * For more information, visit <http://getsproutcms.com>. */ namespace Sprout\Helpers; /** * An autocomplete widget for the refine bar */ class RefineWidgetAutocomplete extends RefineWidget { private $options; /** * @param string $name The field name, e.g. 'name', '_some_foreign_column' * @param string $label The label to display on the form, e.g. 'Name' * @param array $options Options for the autocomplete field; see $options of {@see Fb::autocomplete} * */ public function __construct($name, $label, $options) { parent::__construct($name, $label); $this->options = $options; } /** * Draws the widget. * @return string The HTML for the widget. */ public function render() { Form::setFieldValue($this->name, $this->getValue()); Form::nextFieldDetails($this->label, false); return Form::autocomplete($this->name, ['-wrapper-class' => 'white small'], $this->options); } }
|