diff options
| author | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-01 13:14:11 -0800 |
|---|---|---|
| committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-01 13:14:11 -0800 |
| commit | 809e738536b6639bb42ecae8eb1e183543fed93c (patch) | |
| tree | 585365cff3fb009ebc4ad1d1485f4467791eacb1 /modules/tag | |
| parent | 91c5a9abb7b617e45b547ced6a28c14a64ef760f (diff) | |
Try an new approach to extending forms. Create an extend_form event. For the first attempt replace the comment_add_form and item_add_form events.
Diffstat (limited to 'modules/tag')
| -rw-r--r-- | modules/tag/helpers/tag_event.php | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index 57986e40..cc134766 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -64,16 +64,20 @@ class tag_event_Core { tag::compact(); } - static function item_edit_form($item, $form) { - $url = url::site("tags/autocomplete"); - $form->script("") - ->text("$('form input[id=tags]').ready(function() { + static function extend_form($event_data) { + if (in_array($event_data->id, + array("g-edit-album-form", "g-edit-movie-form", "g-edit-photo-form"))) { + $url = url::site("tags/autocomplete"); + $event_data->form->script("") + ->text("$('form input[id=tags]').ready(function() { $('form input[id=tags]').autocomplete( '$url', {max: 30, multiple: true, multipleSeparator: ',', cacheLength: 1}); });"); - $tag_value = implode(", ", tag::item_tags($item)); - $form->edit_item->input("tags")->label(t("Tags (comma separated)")) - ->value($tag_value); + $tag_value = implode(", ", tag::item_tags($event_data->data)); + $input = empty($event_data->append_to) ? $event_data->form : $event_data->append_to; + $input->input("tags")->label(t("Tags (comma separated)")) + ->value($tag_value); + } } static function item_edit_form_completed($item, $form) { |
