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
Comment #1
mkesicki CreditAttribution: mkesicki commentedComment #2
dczepierga CreditAttribution: dczepierga commented@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
Comment #3
Seph CreditAttribution: Seph commentedIn the following code in user.admin.inc ,in the User module:
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!
Comment #4
Seph CreditAttribution: Seph commented@ dczepierga Any ideas?
Comment #5
dczepierga CreditAttribution: dczepierga commentedIt's hard to say...
U can try debug variable
$form_state['values']
in functionsystem_settings_form_submit
insystem.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
Comment #6
lgomezc CreditAttribution: lgomezc commentedWhen 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']
Comment #7
Seph CreditAttribution: Seph commentedI'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.
Comment #8
Firemyst CreditAttribution: Firemyst commentedI'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: