[Drupal] How to add ckEditor to a custom form in Drupal 7?

| | 1 min read

It is quite easy to add ckEditor to your custom form in Drupal. The only thing you have to do is, add the following lines to your form:

'#type' => 'text_format', 
'#format' => 'full_html',

For example:

$html = 'some html'; 
$form['front'] = array(
'#type' => 'text_format',// to load the ckEditor options
'#format' => 'full_html', 
'#title' => t('Front'),
'#value' => $html,
);

The above code will create a form element with its value inside ckEditor.