Remove previous selected value when cloning
-
I’ve created a Metabox as follow:
add_filter( 'rwmb_meta_boxes', 'elclarin_register_meta_boxes' ); function elclarin_register_meta_boxes( $meta_boxes ) { $prefix = 'rw_'; $posts = get_posts( array( 'post_type' => 'post', 'posts_per_page' => 500, 'post_status' => 'publish' ) ); $options = array(); foreach ($posts as $post) { if ($post->post_title !== "") { $options[$post->ID] = $post->post_title; } } // 1st meta box $meta_boxes[] = array( 'id' => 'related_link', 'title' => __( 'Selección de noticias relacionadas' ), 'pages' => array('post'), 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( 'name' => 'Noticia relacionada', 'id' => $prefix.'related_link', 'type' => 'select_advanced', 'options' => $options, 'clone' => true, 'placeholder' => 'Seleccione una noticia' ), ) ); return $meta_boxes; }This works just fine but it’s possible to remove the selected option before clone the component? What I mean is on pics (linked): first component (holds all the posts), second one (cloned): holds all the posts again and that what I’m trying to prevent since the selected before can’t be there.
Any advice? How I can achieve that if it’s possible?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Remove previous selected value when cloning’ is closed to new replies.