示例#1
0
 /**
  * If $dynamic equal true, the form form is completly rebuild. It is useful if you need to interact to the form with hooks.
  *
  * @param string $name
  * @param string $locale
  * @param boolean $dynamic
  * @param string Custom form class
  * @return Zend_Form
  */
 public function getForm($name, $locale = null, $dynamic = false, $formClass = null)
 {
     $this->getLanguages();
     $table = new Formbuilder_Formbuilder();
     $id = $table->getIdByName($name);
     if (is_numeric($id) == true) {
         $class = $formClass ?: $this->getFormClass();
         if ($dynamic == false) {
             $form = $this->getStaticForm($id, $locale, $class);
         } else {
             $form = $this->getDynamicForm($id, $locale, $class);
         }
         return $form;
     } else {
         return false;
     }
 }
示例#2
0
 /**
  * If $dynamic equal true, the form form is completly rebuild. It is useful if you need to interact to the form with hooks.
  *
  * @param string $name
  * @param string $locale
  * @param boolean $dynamic
  * @param string Custom form class
  * @return Zend_Form
  */
 public function getForm($name, $locale = null, $dynamic = false, $formClass = null)
 {
     $this->getLanguages();
     $table = new Formbuilder_Formbuilder();
     $id = $table->getIdByName($name);
     if (is_numeric($id) == true) {
         $class = $formClass ?: $this->getFormClass();
         if ($dynamic == false) {
             $form = $this->getStaticForm($id, $locale, $class);
         } else {
             $form = $this->getDynamicForm($id, $locale, $class);
         }
         //correctly set recaptcha to https if request is over https
         if (Zend_Controller_Front::getInstance()->getRequest()->isSecure()) {
             /**@var Zend_Form $form */
             $elements = $form->getElements();
             foreach ($elements as $element) {
                 if (get_class($element) == 'Zend_Form_Element_Captcha') {
                     /**@var  Zend_Form_Element_Captcha $element */
                     $cap = $element->getCaptcha();
                     $cap->getService()->setParams(array('ssl' => true));
                 }
             }
         }
         return $form;
     } else {
         return false;
     }
 }