[drupal-devel] [feature] 2 additional hooks to form_textarea to
support module writers who are extending it.
tangent
drupal-devel at drupal.org
Sun Mar 6 16:49:49 UTC 2005
Issue status update for http://drupal.org/node/18417
Project: Drupal
Version: 4.5.2
Component: base system
Category: feature requests
Priority: normal
Assigned to: Anonymous
Reported by: jbond
Updated by: tangent
Status: patch
See my patch in this issue [1] for an example of how to add event
handlers.
[1] http://drupal.org//node/16204
tangent
Previous comments:
------------------------------------------------------------------------
March 5, 2005 - 04:54 : jbond
Attachment: http://drupal.org/files/issues/common.inc_8.patch (1.83 KB)
This patch is for common.inc function form_textarea(). It adds two
additional hooks for module writers.
1) A new hook "post-title" which works the same as "pre" and "post" but
allows html to be inserted between the title of the element and the
textarea. This makes it easier to insert a row of buttons (say) that
sit just on top of the textarea.
2) A new hook "attributes" which takes an array() from modules that
provide it and merges it into the $attributes array for the textarea.
Wysywig editors typically need to add javascript handlers for things
like onClick and this provides a simple way for the module to add them.
------------------------------------------------------------------------
March 5, 2005 - 05:00 : jbond
Attachment: http://drupal.org/files/issues/common.inc_9.patch (1.83 KB)
Apologies. the first patch had ms win line endings. This one should be
unix line endings.
------------------------------------------------------------------------
March 6, 2005 - 04:17 : gordon
-1
I do not think that these 2 additional hooks are needed. This will
really add alot of additional overhead as it is going to call every
textarea hook 4 times for every textarea on a page. Besides these
modifiaction can be handled better and cleaner in the javascript. If
you take a look at Xinha/HTMLArea or FckEditor they both manipulate the
dom once the page has loaded, and not during. This is a much better and
cleaner method as it means that you can attach to any textarea with
only a few commands.
This is what javascript excels at. So I don't think this is needed.
------------------------------------------------------------------------
March 6, 2005 - 05:03 : Dries
I was about to suggest the same as Gordon. IMO, these hooks aren't
really necessary.
------------------------------------------------------------------------
March 6, 2005 - 07:04 : Bèr Kessels
-1 from me too. More hookss are unnecasary.
What *is* neccesary, thoiugh, is to mve the "pre" to inbetween the
title and the area!
------------------------------------------------------------------------
March 6, 2005 - 07:23 : jbond
I'd agree with you, perhaps, about the attributes tag. I don't think I
agree about
"post-title". I think it's highly likely that a module would use "pre"
or "post-
title" but not both.
And since these are all in memory hooks I hardly see that calling 4
module hooks
instead of 2 is going to make any performance difference at all, at
all.
Following your logic there's no need for "pre" either, because you can
implement
that in javascript from "post".
Better and cleaner? I find php a hell of a lot easier to code and debug
in than
Javascript. But then that's just me.
------------------------------------------------------------------------
March 6, 2005 - 07:32 : chx
-1 the way JS should be that you insert an onload handler and there is
no other trace of JS in your code. use DOM.
------------------------------------------------------------------------
March 6, 2005 - 07:59 : gordon
When the textarea hook was first implemented it was only used in the
post. But using the pre for functions other then javascript wil allow
you to place html above the title, which maybe wanted, depending on the
use.
Javascript is the primary use, but I think there is other things that
use it.
As for debugging javascript, this is made extremely easy, actually
easier than php by itself with the use of firefox/mozilla and venkman
[2] the javascript debugger.
[2] http://www.mozilla.org/projects/venkman/
------------------------------------------------------------------------
March 6, 2005 - 08:31 : Bèr Kessels
I meant "Post title" INSTEAD of pre. So:
hook_textare('pre'):
TITLE
------------------------------------------------------------------------
March 6, 2005 - 08:32 : Bèr Kessels
hrm, my cool ascii art example got lost. :(
Hoever: i meant that we should change the behavious of form pre, to be
rendered after the TITLE. and *not* to introduce a third form hook.
More information about the drupal-devel
mailing list