So I have been buildign a simple form used to populate a block on the sidebar of my drupal 7 site. However I have run into a problem, the textarea on this form does not seem to populate with the sidebars previous value.
What has me stumped is that a textfield with the same defaultvalue code populates correctly.
//a debug textfield that works $form['debug'] = array( '#type' => 'textfield' ,'#title' => 'Debug' ,'#default_value' => $sidebar_content[$key] ? $sidebar_content[$key] : '' ,'#description' => t('Please enter a suitable heading for the left sidebar.') ); //the broken textarea $form['body'] = array( '#type' => 'textarea' ,'#title' => t('Body') ,'#rows' => 15 ,'#description' => t('Body text for sidebar') ,'#value' => $sidebar_content[$key] ? $sidebar_content[$key] : '' );
Edit: After disabling WYSIWYG the text area started populating again. More digging revealed the reason it wasn't populating as a rich text box was because when an editor is used it submits the value as an array with two items; value and format. Consequently, this meant that the text editor was being given an array to display rather than a string.
Altering the #default_value to $sidebar_content[$key]['value'] resolved this issue.