From: Steve Sutton Date: Fri, 15 Aug 2014 18:53:17 +0000 (-0400) Subject: Add your event form X-Git-Tag: V1.0^2~61 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=f81b478774b5d9f0ea1be06b3ca6f2e11c6ed30c;p=web%2FKeweenaw.git Add your event form Adding the form. Make form template so it is like the other forms and uses foundation styles. Update to use cdn for jquery-ui and the theme --- diff --git a/Toolkit/Events/AddCommonEventForm.php b/Toolkit/Events/AddCommonEventForm.php index 18e4a6e..d4cc8b2 100644 --- a/Toolkit/Events/AddCommonEventForm.php +++ b/Toolkit/Events/AddCommonEventForm.php @@ -100,6 +100,7 @@ class Toolkit_Events_AddCommonEventForm * @access protected */ protected $subject = 'New Event Submission'; + public $formTemplate = 'form.html'; /** * Message to display if the form is successfully submitted @@ -303,8 +304,8 @@ class Toolkit_Events_AddCommonEventForm // All Elements are created here. This includes group element definitions. $e[] = array( 'type' => 'header', - 'name' => 'eventInfoHdr', - 'display' => 'Event Information' + 'name' => 'eventNameHdr', + 'display' => 'Event Name' ); $e[] = array( 'type' => 'text', @@ -312,6 +313,11 @@ class Toolkit_Events_AddCommonEventForm 'name' => 'header', 'display' => 'Event Name' ); + $e[] = array( + 'type' => 'header', + 'name' => 'eventDateHdr', + 'display' => 'Event Date / Time' + ); $e[] = array( 'type' => 'text', 'req' => true, @@ -365,6 +371,11 @@ class Toolkit_Events_AddCommonEventForm ), ), ); + $e[] = array( + 'type' => 'header', + 'name' => 'eventInfoHdr', + 'display' => 'Event Information' + ); $e[] = array( 'type' => 'select', 'req' => true, @@ -529,7 +540,8 @@ class Toolkit_Events_AddCommonEventForm 'type' => 'submit', 'req' => false, 'name' => 'submit_rmv', - 'display' => 'Submit' + 'display' => 'Submit', + 'opts' => array('class' => 'button') ); $this->setupElements($e); @@ -957,18 +969,20 @@ class Toolkit_Events_AddCommonEventForm */ protected function setupRenderers() { - parent::setupRenderers(); - $renderer = $this->defaultRenderer(); - $required = '*'; - $error = '
{error}
'; + $formConfig = new Zend_Config_Ini( + BASE . 'Toolkit/Events/application.ini', + strtolower($_ENV['GLM_HOST_ID']) + ); - $renderer->setElementTemplate('' . $required . '{label}' . $error . '{element}', 'descr'); - $renderer->setElementTemplate('' . $required . '{label}' . $error . '{element}', 'submit_rmv'); + $renderer = new HTML_QuickForm_Renderer_Object(true); + $this->accept($renderer); + $this->template = new HTML_Template_Flexy( + $formConfig->flexyOptions->toArray() + ); - if ($this->useCaptcha) { - $renderer->setElementTemplate('{element}', 'captcha_question'); - $renderer->setElementTemplate('' . $required . '' . $error . '{element}What is this?', 'captcha_rmv'); - } + $this->view = $this; + $this->view->form = $renderer->toObject(); + $this->template->compile($this->formTemplate); } // }}} @@ -985,7 +999,6 @@ class Toolkit_Events_AddCommonEventForm */ public function toHtml() { - $this->setupRenderers(); if ($this->validate()) { $this->captchaQuestion->destroy(); $this->cleanForm(); @@ -1003,11 +1016,9 @@ class Toolkit_Events_AddCommonEventForm } $output = $this->errorMsg; $GLOBALS['topScripts'][] - = MEDIA_APP_BASE_URL - . 'libjs/jqueryui/1.8.13/js/jquery-ui-1.8.13.custom.min.js'; + = '//code.jquery.com/ui/1.11.1/jquery-ui.min.js'; $GLOBALS['styleSheets'][] - = MEDIA_APP_BASE_URL - . 'libjs/jqueryui/1.8.13/development-bundle/themes/base/jquery.ui.all.css'; + = '//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css'; $GLOBALS['bottomScripts'][] = MEDIA_APP_BASE_URL . 'libjs/textlimit.js'; $GLOBALS['topScripts'][] = 'http://maps.googleapis.com/maps/api/js?sensor=true'; @@ -1015,18 +1026,17 @@ class Toolkit_Events_AddCommonEventForm = MEDIA_BASE_URL . 'Toolkit/Maps/geoCoder.js'; $GLOBALS['bottomScripts'][] = MEDIA_BASE_URL . 'Toolkit/Events/libjs/addEvent.js'; - $output .= parent::toHtml(); + $output = $this->errorMsg; + $output .= $this->template->bufferedOutputObject($this->view); } else { if ($this->useCaptcha) { $this->captchaQuestion->destroy(); $this->captchaAnswer->setValue(''); } $GLOBALS['topScripts'][] - = MEDIA_APP_BASE_URL - . 'libjs/jqueryui/1.8.13/js/jquery-ui-1.8.13.custom.min.js'; + = '//code.jquery.com/ui/1.11.1/jquery-ui.min.js'; $GLOBALS['styleSheets'][] - = MEDIA_APP_BASE_URL - . 'libjs/jqueryui/1.8.13/development-bundle/themes/base/jquery.ui.all.css'; + = '//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css'; $GLOBALS['bottomScripts'][] = MEDIA_APP_BASE_URL . 'libjs/textlimit.js'; $GLOBALS['topScripts'][] = 'http://maps.googleapis.com/maps/api/js?sensor=true'; @@ -1034,7 +1044,8 @@ class Toolkit_Events_AddCommonEventForm = MEDIA_BASE_URL . 'Toolkit/Maps/geoCoder.js'; $GLOBALS['bottomScripts'][] = MEDIA_BASE_URL . 'Toolkit/Events/libjs/addEvent.js'; - $output = parent::toHtml(); + $this->setupRenderers(); + $output .= $this->template->bufferedOutputObject($this->view); } return $output; } diff --git a/Toolkit/Events/application.ini b/Toolkit/Events/application.ini new file mode 100644 index 0000000..121f873 --- /dev/null +++ b/Toolkit/Events/application.ini @@ -0,0 +1,23 @@ +; Production server configuration data +[production] +; flexyOptions +flexyOptions.templateDir = BASE "Toolkit/Events/templates" +flexyOptions.compileDir = BASE "Toolkit/Events/templates/compiled" +flexyOptions.forceCompile = Off +flexyOptions.allowPHP = On + +; development server configuration data inherits from production and +; overrides values as necessary +[development : production] + +; chuck's server configuration data inherits from development +; and overrides values as necessary +[chuck : development] + +; steve's server configuration data inherits from development +; and overrides values as necessary +[steve : development] + +; Vagrant server configuration inherits from development and +; overrides values as needed +[vagrant : development] diff --git a/Toolkit/Events/libjs/addEvent.js b/Toolkit/Events/libjs/addEvent.js index b912912..ebdffb7 100644 --- a/Toolkit/Events/libjs/addEvent.js +++ b/Toolkit/Events/libjs/addEvent.js @@ -21,6 +21,7 @@ var AddEvent = e.preventDefault(); $("#map-dialog").dialog('open'); GLM_GeoMap.initialize(); + return false; }); } } diff --git a/Toolkit/Events/templates/form.html b/Toolkit/Events/templates/form.html new file mode 100644 index 0000000..34f1676 --- /dev/null +++ b/Toolkit/Events/templates/form.html @@ -0,0 +1,104 @@ + + {form.javascript:h} + {form.outputHeader():h} + {form.hidden:h} + {hidden} + + {foreach:form.sections,sec} + {if:sec.header} +
+ {sec.header:h} + {end:} +
+ {foreach:sec.elements,elem} + {if:elem.style} + {elem.outputStyle():h} + {else:} + {if:elem.isButton()} + {if:elem.notFrozen()} +
{elem.html:h}
+ + {end:} + {else:} + {if:elem.error} +
+ {else:} +
+ {end:} + {if:elem.isType(#textarea#)} + {if:elem.required}
+ {end:} + {end:} + {end:} +
+ + {if:sec.header} +
+ {end:} + {end:} + + + + {if:form.requirednote} +
{form.requirednote:h}
+ {end:} + diff --git a/Toolkit/FormBuilder.php b/Toolkit/FormBuilder.php index 4eb5592..a95d669 100644 --- a/Toolkit/FormBuilder.php +++ b/Toolkit/FormBuilder.php @@ -1205,7 +1205,7 @@ abstract class Toolkit_FormBuilder extends HTML_QuickForm */ public function useCaptcha($useCaptcha) { - $this->useClueTip(); +// $this->useClueTip(); $this->useCaptcha = $useCaptcha; } diff --git a/static/40.phtml b/static/40.phtml new file mode 100644 index 0000000..536bac4 --- /dev/null +++ b/static/40.phtml @@ -0,0 +1,38 @@ +useCaptcha(true); + $form->setAutoValidateDateElements(false); + $form->configureForm(); + echo $form->toHtml(); +} else { + $scriptTag = << +$(document).ready(function(){ + $("textarea[name='descr']").textlimit('span.counter',1000); +}); + +EOD; + $form = new Toolkit_Events_AddEventForm( + Toolkit_Database::getInstance(), + 'new_event' + ); + $form->useCaptcha(true); + $form->setAutoValidateDateElements(false); + $form->configureForm(); + echo $form->toHtml(); +}