WordPress.org

Ready to get started?Download WordPress

Forums

wp_editor textarea value not updating (2 posts)

  1. oste
    Member
    Posted 2 years ago #

    I am using the *_add_form_fields action to add fields to the edit/add term page. One of those fields is a wp_editor().

    The problem I am facing is that when I output the WordPress editor on the page like so:

    wp_editor('test', 'mydescription', array('textarea_name' => 'my_description'));

    and then if I click in the editor on the page and change the default value from test to something else the $_POST['my_description'] variable is still set to test

    Should I be adding an additional setting to my editor? Is there a reason why I cannot change the value of the textarea?

    Below is a simple test case that shows this. You can paste this code at the top of twentyeleven/functions.php in a default install of
    WordPress. Then visit the add tag page and try to add a tag. You will notice that the posted value for my_description will not change...

    class Test{
    
    	function __construct() {
    
    		add_action('add_tag_form_fields', array($this, 'add_tag_form_fields'));
    		add_action('created_term', array($this, 'created_term'));
    	}
    
    	function add_tag_form_fields($tag){
    
    		if ( current_user_can( 'publish_posts' ) ):
    
    			wp_editor('test', 'mydescription', array('textarea_name' => 'my_description'));
    
    		endif;
    	}
    
    	function created_term($tag){
    		echo '<pre>';
    		print_r($_POST);
    		echo '</pre>';
    		die();
    	}
    }
    new Test();
  2. oste
    Member
    Posted 2 years ago #

    I think that this has to do with the fact that the add tag/taxonomy page uses ajax to post the data.

    I came to this conclusion b/c if you add the same wp_editor to the edit page everything works as expected...

    I hope this can be resolved soon.

Topic Closed

This topic has been closed to new replies.

About this Topic