Hello,
I have been reading the discussion at http://drupal.org/node/81297, and found it very interesting. Especially the details about the addition of the '#wysiwyg' attribute.
I have a form that contains multiple textareas, and currently the wysiwyg.module is applying editors to all of them, so I plan to use the '#wysiwyg' attribute to over come this.
Is there a way to disable multiple textareas without having to code specific cases for each field?
So instead of :
$form[textarea-1][#wysiwyg] = false;
$form[textarea-2][#wysiwyg] = false;
... etc
Can I do something like:
$form[field-type][textarea][#wysiwyg] = false;
Any help would be great.
Comments
Comment #1
sunUnfortunately, no. You would have to use element_children($form) to iterate over all form fields (recursively). I would be interested in everything you come up with.
Also, there is no setting to switch the overall default value of #wysiwyg to FALSE, so you could selectively set it to TRUE on certain fields only. I think this would be valuable to have, but requires a lot of consideration and development.
Comment #2
emTque CreditAttribution: emTque commentedi have made a little headway with this, but it is not working completely.
i used the form_alter hook in one of my contrib modules to iterate through the form fields as you suggested with the following code:
this was based on the form_alter i found in "jscalendar.module".
i then created a white-list of textareas where i wanted the wysiwyg editor, using the $form array:
this worked fine for every field except those that are added by the Workflow module. it seems that these are added after my form_alter is finished with the $form array, so i can't target them.
any suggestions??
Comment #3
sunYes, that's possible. You need to increase the weight of your module to a value that is higher than the weight of workflow module. Module weights are stored in the 'system' database table.
Comment #4
emTque CreditAttribution: emTque commentedYES!!!
thanks sun!!!
that worked and now my forms are working fine. thanks for your help.
Comment #5
sunBetter title to not screw other users away.
Comment #6
sunMarking as duplicate of #253600: Attach client-side editors to input format enabled textareas only