Title: Remove previous selected value when cloning
Last modified: August 22, 2016

---

# Remove previous selected value when cloning

 *  Resolved [reypm](https://wordpress.org/support/users/reypm/)
 * (@reypm)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/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](http://content.screencast.com/users/ReynierPM/folders/Snagit/media/0b3899bf-da1d-4ff1-9b1e-6ad84ed7b177/02.16.2015-20.46.png)(
   holds all the posts), [second one](http://content.screencast.com/users/ReynierPM/folders/Snagit/media/be3637e5-770d-4472-a2d3-c83e24aa139f/02.16.2015-20.43.png)(
   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?
 * [https://wordpress.org/plugins/meta-box/](https://wordpress.org/plugins/meta-box/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Anh Tran](https://wordpress.org/support/users/rilwis/)
 * (@rilwis)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/remove-previous-selected-value-when-cloning/#post-5797180)
 * I’m not sure if we can do that _easily_ with select2 library or even with normal
   select dropdown. The plugin doesn’t support this in its core.
 * To do this, you should create a custom field type, enqueue your custom javascript
   code and handle the clone job in your way. I wrote a documentation for this purpose
   [here](http://metabox.io/docs/create-field-type/), please take a look.
 * Thank you.

Viewing 1 replies (of 1 total)

The topic ‘Remove previous selected value when cloning’ is closed to new replies.

 * ![](https://ps.w.org/meta-box/assets/icon-128x128.png?rev=1100915)
 * [Meta Box](https://wordpress.org/plugins/meta-box/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/meta-box/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/meta-box/)
 * [Active Topics](https://wordpress.org/support/plugin/meta-box/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/meta-box/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/meta-box/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Anh Tran](https://wordpress.org/support/users/rilwis/)
 * Last activity: [11 years, 5 months ago](https://wordpress.org/support/topic/remove-previous-selected-value-when-cloning/#post-5797180)
 * Status: resolved