By default, the module is enabled for all textareas, even those associated with plain text fields, i.e. custom fields that do not support HTML formatting.

I found when testing this module that when editing a content type with such a field, every time I edit and save, an additional three empty values are saved for the field. For example, if the field is "Notes", then the dev load after one edit / save cycle might look like this:

field_notes

Array
(
    [0] => Array
        (
            [value] => Copyrights 2002/2006
        )

    [1] => Array
        (
            [value] =>
        )

    [2] => Array
        (
            [value] =>
        )
    [3] => Array
        (
            [value] =>
        )
)

This problem goes away if I do not allow the whizzywig editing for this field.

Is it possible to check for the field type and disallow if it is a plain text field? Otherwise, documenting this will be helpful.

Comments

sdecabooter’s picture

I suppose you are talking about CCK fields?
I don't think there's a way to check if a text field is supposed to be plain text or not.

I do know that the Whizzywig module hasn't been tested thoroughly with CCK fields yet.
I'll try to reproduce your problem and come up with a solution (it might take a while... i'm rather busy right now)

Thanks for reporting.

sdecabooter’s picture

Assigned: Unassigned » sdecabooter
leeksoup’s picture

Yes, it is a CCK field. In fact most of my DB consists of custom content types built with CCK.

This info (i.e. whether the field is plain text or HTML) must be availabe somewhere otherwise the edit widget would not "know" whether to include the "input format" dropdown or not. Unfortunately, I don't know exactly where.

Thanks for looking into it.

sdecabooter’s picture

Is this fixed by the changes you suggested in this comment: http://drupal.org/node/179496#comment-326078 ?

leeksoup’s picture

No. The two are completely unrelated.

I would guess that the problem above is caused by whizzywig returning some non-empty value for the additional fields in the edit form. These then get saved.

OK, I did a bit of digging and find that it (whizzywig) returns some kind of newline character at the beginning of every field for which it is enabled, even when the user leaves the field empty. This character is what causes the "empty" field values to be saved.

leeksoup’s picture

I found this info while searching for something else. I hope it helps.

If you want to find out the "type" of a field, you can do:

$field = content_fields ('<field_name>');
// At this point, $field[type] will be "text" for a text field
// and $field[text_processing] will tell you whether it is a plain text field (0)
leeksoup’s picture

It would be very nice to check the type of text fields and automatically disable whizzywig for plain text fields, but meanwhile users can just disable it for those fields manually by using the feature to enable / disable for listed form IDs. The fix in http://drupal.org/node/179496 may be needed for this workaround to work correctly.

sdecabooter’s picture

Hi leeksoup,

I tried implementing a check for the CCK fields.
Partly based on the code you provided, it checks whether
- a textarea is a CCK textfield
- if so, if it's plaintext or rich text

If it turns out to be plaintext, the editor is not loaded.

I updated the code for the -dev release to support this. Can you run some tests if this fixes your issue (and does not create new issues :p) ?

Thanks

leeksoup’s picture

Hi Sven,

I am busy right now getting other things fixed on my site but I hope to check out your fix within the week.

Thanks for implementing!

drupalnesia’s picture

Status: Active » Closed (fixed)

Whizzywig version 6.x supports enable/disable editor for certain TEXTAREA ID. You can enable/disable editor for certain CCK textarea field.

Please upgrade to Drupal 6 and use Whizzywig 6.x version, thanks.