I’m hoping someone can assist me. I’m trying to allow a multiple selection on a webpage via PHP, but whilst the list is showing, I cannot get the HTML to call the multiple option.
PHP:
<?php $select_features = New_Options::select_form( Property_A::get_property_features( 'id' ), array( 'id' => 'property_feature', 'name' => 'property_feature[]', 'multiple' => true, 'default' => esc_html__( 'Select', 'name-estate-agent' ), 'echo' => false, ) ); ?> <?php if ( ! empty( $select_features ) ) { ?> <div class="prop-sub-form__group"> <label for="property_feature"><?php esc_html_e( 'Features', 'name-estate-agent' ); ?></label> <?php echo $select_features; ?> </div> <?php } ?>
And the HTML being called:
<div class="prop-sub-form__group"> <label for="property_feature">Features</label> <select name="property_feature[]" id="property_feature[]"><option value="">Select</option><option value="38" >Air conditioning</option><option value="62" >Annexe</option><option value="39" >Balcony</option><option value="46" >Concrete Flooring</option><option value="58" >Garden</option><option value="61" >Gym</option><option value="59" >Indoor Pool</option><option value="57" >Off-street Parking</option></select></div>
As you can see, the name is getting the [] multi-select feature, but the multiple=’multiple’ is missing. I don’t know where I’m going wrong.
Thanks,
Advertisement
Answer
<select name="property_feature[]" multiple="multiple">
you can get multi-value from select property