| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * |
||
| 5 | * @package sitemaker |
||
| 6 | * @copyright (c) 2019 Daniel A. (blitze) |
||
| 7 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
||
| 8 | * |
||
| 9 | */ |
||
| 10 | |||
| 11 | namespace blitze\sitemaker\services\blocks\config\fields; |
||
| 12 | |||
| 13 | use blitze\sitemaker\services\blocks\config\cfg_utils; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @package sitemaker |
||
| 17 | */ |
||
| 18 | class multi_select extends cfg_field_base |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * @inheritdoc |
||
| 22 | */ |
||
| 23 | public function get_name() |
||
| 24 | { |
||
| 25 | return 'multi_select'; |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * {@inheritdoc} |
||
| 30 | */ |
||
| 31 | public function prep_field(array &$vars, array &$type, $field, array $db_settings) |
||
| 32 | { |
||
| 33 | $vars['method'] = 'build_multi_select'; |
||
| 34 | $vars['params'][] = $field; |
||
| 35 | $type[0] = 'custom'; |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Used to add multi-select drop down in blocks config |
||
| 40 | * |
||
| 41 | * @param array $option_ary |
||
| 42 | * @param mixed $selected_items |
||
| 43 | * @param string $field |
||
| 44 | * @return [] |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 45 | */ |
||
| 46 | public function build_multi_select(array $option_ary, $selected_items, $field) |
||
| 47 | { |
||
| 48 | return array( |
||
| 49 | 'field' => $field, |
||
| 50 | 'options' => $option_ary, |
||
| 51 | 'selected' => cfg_utils::ensure_array($selected_items), |
||
| 52 | ); |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * {@inheritdoc} |
||
| 57 | */ |
||
| 58 | public function get_template() |
||
| 59 | { |
||
| 60 | return '@blitze_sitemaker/cfg_fields/multi_select.html'; |
||
| 61 | } |
||
| 62 | } |
||
| 63 |