Title: [Plugin: Gravity Forms WYSIWYG] DefaultValue not working
Last modified: August 20, 2016

---

# [Plugin: Gravity Forms WYSIWYG] DefaultValue not working

 *  Resolved [reipan](https://wordpress.org/support/users/reipan/)
 * (@reipan)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-gravity-forms-wysiwyg-defaultvalue-not-working/)
 * hey folks,
    first of all thx for your great plugin. There is just one thing, 
   which keeps me from using it. In order to allow a user to edit some texts, i 
   need to prepoluate the wysiwyg-field. Assigning the text to the ‘defaultValue’
   attribute doesnt work like on every other gravityforms field. Maybe someone has
   experienced the same issue and can provide some assistance.
 * regards, bene.
 * [http://wordpress.org/extend/plugins/gravity-forms-wysiwyg/](http://wordpress.org/extend/plugins/gravity-forms-wysiwyg/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Phil](https://wordpress.org/support/users/philnelsonweb/)
 * (@philnelsonweb)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/plugin-gravity-forms-wysiwyg-defaultvalue-not-working/#post-2881709)
 * I came across the same issue and welcome corrections/feedback to the approach
   below. In addition to fully enabling GF’s dynamic population, this appears to
   be an alternative resolution to the problem of wysiwyg field content not being
   retained when validation fails, discussed [here](http://wordpress.org/support/topic/plugin-gravity-forms-wysiwyg-retain-wysiwyg-field-content-if-form-returns-an-error).
   It could also be an opportunity to incorporate the wp media button, as discussed
   [here](http://wordpress.org/support/topic/plugin-gravity-forms-wysiwyg-media-button).
 * Because we’ll replace the functionality of the wysiwyg_enqueue_scripts() function
   elsewhere, comment out line 27 in the file gf_wysiwyg_class.php:
 * > `// add_action( 'gform_enqueue_scripts' , array(&$this, 'wysiwyg_enqueue_scripts'),
   > 10 , 2 );`
 * For good measure, comment out the entire associated wysiwyg_enqueue_scripts()
   function starting on line 105. We’ll insert its functionality into the wysiwyg_field_input()
   function where we have access to the $value parameter we’ll pass to the wp_editor()
   function for dynamic population. Go ahead and replace the entire wysiwyg_field_input()
   function (starts on line 67) with this:
 *     ```
       function wysiwyg_field_input( $input, $field, $value, $lead_id, $form_id ) {
         if ( $this->is_wysiwyg($field) ) {
   
       	$input_id = 'input_' . $form_id . '_' . $field["id"];
   
       	if (is_admin()) {
   
       	  $tabindex = GFCommon::get_tabindex();
       	  return sprintf("<div class='ginput_container'><textarea readonly name='input_%s' id='input_%s' class='textarea gform_wysiwyg' {$tabindex} rows='10' cols='50'>WYSIWYG editor</textarea></div>", $field["id"], 'wysiwyg-'.$field['id']);
   
       	} else {
   
       		$args = array(
       			'textarea_name' => 'input_'.$field["id"],
       			'wpautop' => true,
       			'media_buttons' => false, // possibly true
       			'editor_class' => 'frontend',
       			'textarea_rows' => 5,
       			'tabindex' => 0 //$tabindex
       		);          
   
       		ob_start();
       		wp_editor($value, $input_id, $args);
       		$html = ob_get_contents();
       		ob_end_clean();
   
       		return "<div class='ginput_container'>" . $html . "</div>";
       	}
   
         }
   
         return false;
       }
       ```
   
 * I tested the above with WP v3.4.2, GF v1.6.10, and GF + WYSIWYG v0.1 beta. It
   works for me with all methods of dynamic population I’m aware of (query string,
   shortcode, hooks, $field_values parameter of gravity_form() function, and “Default
   Value” set for field in the form editor in the admin).
 * Obviously, you’ll want to test it fully before using on your production site.
   As time permits, maybe the plugin author will comment on whether this breaks 
   something and whether it fits with the rest of the code conceptually.
 *  Plugin Author [bradvin](https://wordpress.org/support/users/bradvin/)
 * (@bradvin)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/plugin-gravity-forms-wysiwyg-defaultvalue-not-working/#post-2881713)
 * Hi Phil
 * Thanks so much for the code – I am looking at updating this plugin in the next
   week and will fully test and incorporate your code accordingly
 * cheers
    Brad
 *  [Kevin Ryman](https://wordpress.org/support/users/kevinryman/)
 * (@kevinryman)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/plugin-gravity-forms-wysiwyg-defaultvalue-not-working/#post-2881731)
 * Thanks Phil! Any news on the update, Brad? :]
 *  [nahyanshiwani](https://wordpress.org/support/users/nahyanshiwani/)
 * (@nahyanshiwani)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/plugin-gravity-forms-wysiwyg-defaultvalue-not-working/#post-2881770)
 * How can we auto-fill the wysiwyg-field when editing a post from front-end?
    For
   other GF fields there is a checkbox to allow field to be populated dynamically
   with shortcodes or hooks.
 *  Plugin Author [bradvin](https://wordpress.org/support/users/bradvin/)
 * (@bradvin)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/plugin-gravity-forms-wysiwyg-defaultvalue-not-working/#post-2881801)
 * Hey all – I have updated the plugin to use a modified variation of this code
 * V0.2 beta now fixes a couple bugs and also adds support for enabling the media
   buttons
 * thanks again to Phil for posting his code

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘[Plugin: Gravity Forms WYSIWYG] DefaultValue not working’ is closed to
new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/gravity-forms-wysiwyg_636362.svg)
 * [Gravity Forms WYSIWYG](https://wordpress.org/plugins/gravity-forms-wysiwyg/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gravity-forms-wysiwyg/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gravity-forms-wysiwyg/)
 * [Active Topics](https://wordpress.org/support/plugin/gravity-forms-wysiwyg/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gravity-forms-wysiwyg/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gravity-forms-wysiwyg/reviews/)

## Tags

 * [GravityForms](https://wordpress.org/support/topic-tag/gravityforms/)

 * 5 replies
 * 5 participants
 * Last reply from: [bradvin](https://wordpress.org/support/users/bradvin/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/plugin-gravity-forms-wysiwyg-defaultvalue-not-working/#post-2881801)
 * Status: resolved