Hi I bought a theme but I need to add some fields to a frontend submission form. I added the metaboxes and they are working but the problem is the select type of metaboxes.
I cloned a select form group that gets the data from the post taxonomies but I don't know how to tweak it to make it "grab" the data from the 'items' array.
Here's my metabox:
array(
'type' => 'select',
'name' => 'resume_change_location',
'label' => __( 'Are you willing to change location?', 'jobboard' ),
'description' => __( '' ),
'items' => array(
array(
'value' => 'yes',
'label' => __( 'Yes', 'jobboard' ),
),
array(
'value' => 'no',
'label' => __( 'No', 'jobboard' ),
),
),
),
Here's the dropdown for the taxonomy data (working):
<select name="job_type" id="job_type" class="form-control">
<option value=""><?php echo '-- '.__( 'Select Type', 'jobboard' ).' --'; ?></option>
<?php
$terms = get_terms( 'job_type', array( 'hide_empty' => false, ) );
foreach( $terms as $term ){
$selected = '';
if( $default['job_type'] == $term->slug ){
$selected = 'selected';
}
echo '<option value="'.$term->slug.'" '.$selected.'>'.esc_attr($term->name).'</option>';
}
?>
</select>
I would like to show the dropdown with the items in my metabox...here's what I got but it is not showing my items (it is showing the dropdown but with blank options)
<select class="form-control" name="change">
<option value=""><?php _e( 'Select', 'jobboard' ); ?></option>
<?php
$change = get_post_meta($post->ID, $key, 'resume_change_location', true);
foreach( $change as $key){
$selected = '';
if( $key->name == $default['resume_change_location'] ){
$selected = 'selected="selected"';
}//endif;
echo '<option value="'.$key->name.'" '.$selected.'>'.esc_attr($key->name).'</option>';
}
?>
</select>
I have been looking for a way to make this work for about 3 hours with no luck... Any help is highly appreciated.