PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / Form / LegacyConsumer / templates / select.html.php

select.html.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/Form/LegacyConsumer/templates/select.html.php

50 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /** @var Give\Framework\FieldsAPI\Select $field */ ?>
3 <?php
4 /** @var string $fieldIdAttribute */ ?>
5
6 <select
7 name="<?php
8 echo $field->getName(); ?><?php
9 echo $field->getAllowMultiple() ? '[]' : ''; ?>"
10 id="<?php
11 echo $fieldIdAttribute; ?>"
12 <?php
13 echo $field->getAllowMultiple() ? 'multiple' : ''; ?>
14 <?php
15 echo $field->isRequired() ? 'required' : ''; ?>
16 <?php
17 echo $field->isReadOnly() ? 'readonly' : ''; ?>
18 >
19 <?php
20 if ($placeholder = $field->getPlaceholder()) {
21 printf(
22 '<option value="" %2$s %3$s>%1$s</option>',
23 $placeholder,
24 $field->isRequired() ? 'disabled' : '',
25 $field->getDefaultValue() ? '' : 'selected'
26 );
27 }
28 ?>
29 <?php
30 foreach ($field->getOptions() as $option) : ?>
31 <?php
32 $value = esc_attr($option->getValue());
33 $label = $option->getLabel();
34 $default = $field->getAllowMultiple() ?
35 in_array($option->getValue(), $field->getDefaultValue()) :
36 $field->getDefaultValue() === $option->getValue();
37 ?>
38 <option
39 <?php
40 echo $label ? "value=\"$value\"" : ''; ?>
41 <?php
42 echo $default ? 'selected' : ''; ?>
43 >
44 <?php
45 echo $label ?: $value; ?>
46 </option>
47 <?php
48 endforeach; ?>
49 </select>
50