Tax-Meta-Class icon indicating copy to clipboard operation
Tax-Meta-Class copied to clipboard

Problems adding options to select field

Open DDave995 opened this issue 7 years ago • 0 comments

Problems on filling 'options' for select fields.

I'm trying to add multiple options to a select field, if I do this by just filling in keys and values into an array() and using this array into your code it works fine!

$twosectors = array( 'belleza'=>'Belleza', 'centros-estetica'=> 'Centros de estética', 'centros-depilacion-laser'=>'Centros depilación laser', 'centros-manicura-pedicura'=>'Centros manicura y pedicura', 'peluquerias'=>'Peluquerías', 'tatuajes-piercings'=>'Tatuajes y piercings' );

$my_meta->addSelect($prefix.'select_field_id',$twosectors,array('name'=> __('Related sector 1 ','tax-meta'), 'std'=> array('Related ')));


But if I'm trying to do the same but filling keys and values from terms, it does not work... options stay empty. Comparing arrays content they are just the same, why doesn't it work ?

$mysectors = array(); $args = array( 'taxonomy' => 'sector', 'hide_empty' => 0 );

$myterms= get_terms($args); if (isset($myterms) ) { foreach ( $myterms as $myterm ) { $name = $myterm->name; $slug = $myterm->slug; $mysectors[$slug]=$name;

}

}

$my_meta->addSelect($prefix.'select_field_id',$mysectors,array('name'=> __('Related sector 1 ','tax-meta'), 'std'=> array('Related ')));

I would be very happy to get it to work!

Thanks for your marvelous script!

DDave995 avatar Feb 23 '18 10:02 DDave995