From 809e738536b6639bb42ecae8eb1e183543fed93c Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 1 Nov 2009 13:14:11 -0800 Subject: 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. --- modules/recaptcha/config/recaptcha.php | 24 ++++++++++++++++++++++++ modules/recaptcha/helpers/recaptcha_event.php | 10 +++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 modules/recaptcha/config/recaptcha.php (limited to 'modules/recaptcha') diff --git a/modules/recaptcha/config/recaptcha.php b/modules/recaptcha/config/recaptcha.php new file mode 100644 index 00000000..04827673 --- /dev/null +++ b/modules/recaptcha/config/recaptcha.php @@ -0,0 +1,24 @@ +add_comment->recaptcha("recaptcha")->label("")->id("g-recaptcha"); + static function extend_form($event_data) { + // @todo put into an admin interface + $config = Kohana::config("recaptcha"); + if (module::get_var("recaptcha", "public_key") && + in_array($event_data->id, $config["recaptcha"])) { + $input = empty($event_data->append_to) ? $event_data->form : $event_data->append_to; + $input->recaptcha("recaptcha")->label("")->id("g-recaptcha"); } } -- cgit v1.2.3