base.html.php
4 years ago
checkbox.html.php
4 years ago
file.html.php
4 years ago
hidden.html.php
4 years ago
html.html.php
4 years ago
label-content.html.php
4 years ago
label.html.php
4 years ago
radio.html.php
4 years ago
select.html.php
4 years ago
textarea.html.php
4 years ago
select.html.php
39 lines
| 1 | <?php /** @var Give\Framework\FieldsAPI\Select $field */ ?> |
| 2 | <?php /** @var string $fieldIdAttribute */ ?> |
| 3 | <?php /** @var string $visibilityConditionsAttribute */ ?> |
| 4 | |
| 5 | <select |
| 6 | name="<?php echo $field->getName(); ?><?php echo $field->getAllowMultiple() ? '[]' : ''; ?>" |
| 7 | id="<?php echo $fieldIdAttribute; ?>" |
| 8 | <?php echo $field->getAllowMultiple() ? 'multiple' : ''; ?> |
| 9 | <?php echo $field->isRequired() ? 'required' : ''; ?> |
| 10 | <?php echo $field->isReadOnly() ? 'readonly' : ''; ?> |
| 11 | <?php echo $visibilityConditionsAttribute ?> |
| 12 | > |
| 13 | <?php |
| 14 | if ( $placeholder = $field->getPlaceholder() ) { |
| 15 | printf( |
| 16 | '<option value="" %2$s %3$s>%1$s</option>', |
| 17 | $placeholder, |
| 18 | $field->isRequired() ? 'disabled' : '', |
| 19 | $field->getDefaultValue() ? '' : 'selected' |
| 20 | ); |
| 21 | } |
| 22 | ?> |
| 23 | <?php foreach ( $field->getOptions() as $option ) : ?> |
| 24 | <?php |
| 25 | $value = esc_attr( $option->getValue() ); |
| 26 | $label = $option->getLabel(); |
| 27 | $default = $field->getAllowMultiple() ? |
| 28 | in_array( $option->getValue(),$field->getDefaultValue() ) : |
| 29 | $field->getDefaultValue() === $option->getValue(); |
| 30 | ?> |
| 31 | <option |
| 32 | <?php echo $label ? "value=\"$value\"" : ''; ?> |
| 33 | <?php echo $default ? 'selected' : ''; ?> |
| 34 | > |
| 35 | <?php echo $label ?: $value; ?> |
| 36 | </option> |
| 37 | <?php endforeach; ?> |
| 38 | </select> |
| 39 |