I was able to get CKEditor to appear in the text areas on the Account Settings page, but I couldn't save any of the edits. All text would disappear and I would get the following message:

Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain() (line 1572 of /Users/Aeons/Sites/intl-alchemical.org/includes/bootstrap.inc).

The basic format I used to get CKEditor to appear was this:

$form['formItem'] = array(
'#type'=>'text_format',
'#title' => t('Field Label'),
'#value' => 'This is my value',
'#format'=>'full_html',
);

I basically just changed the type to 'text_format' and 'added full_html' in the admin.inc file. I know that you're not supposed to hack core, but I was just trying it on my dev site to see if I could get it to work. I'm still fairly new to Drupal and don't know a lot about coding. Do I need to write my own module? What is the best way to approach this?

Comments

mkesicki’s picture

Priority: Major » Normal
dczepierga’s picture

Status: Active » Postponed (maintainer needs more info)

@Seph, try to debug what u get in this field before hack the core, and after hack the core...
Could u also write here what u change and where?

Greetings

Seph’s picture

In the following code in user.admin.inc ,in the User module:

 $form['email_admin_created']['user_mail_register_admin_created_body'] = array(
    '#type' => 'textarea',
    '#title' => t('Body'),
    '#default_value' => _user_mail_text('register_admin_created_body', NULL, array(), FALSE),
    '#rows' => 15,
  );

I changed the type to:

'#type'=> 'text_format',

and added:

'#format'=>'full_html',

CKEditor appeared, but I got the error message I posted above. I couldn't save any changes and the default message disappeared. Technically, I believe I should be able to get this to work.

Thanks!

Seph’s picture

@ dczepierga Any ideas?

dczepierga’s picture

It's hard to say...
U can try debug variable $form_state['values'] in function system_settings_form_submit in system.module file (System module - line 2776).
If u list this variable u probably will see what u get after form submit, and then change code to save your content correctly.

Greetings

lgomezc’s picture

When you use filtered text your info is saved as an Array('value'=>'your text','filter'=>filter), so you have to set the default value like $myvalue['value']

Seph’s picture

I'm pretty new to coding. Is it possible to give me an example? I thought the default text was already
set in the above code.

Firemyst’s picture

Priority: Normal » Major

I've had problems where the response expected is supposed to be text, but CKEditor returns an array. I've not been able to figure this out, and had to write custom hooks to deal with any parsing of fields that use CKEditor. This seems like a rather major bug.

Example: Saving a user that has CKEditor for signatures:

Notice: Array to string conversion in drupal_write_record() (line 7117 of [...]/pressflow/includes/common.inc).