Example #1
0
 /**
  * Renders element
  *
  * @param HTML_QuickForm_element $element element
  * @param bool $required if input is required field
  * @param string $error error message to display
  */
 function renderElement(&$element, $required, $error)
 {
     // Make sure the element has an id.
     $element->_generateId();
     //adding stuff to place holders in template
     //check if this is a group element first
     if ($this->_inGroup and !empty($this->_groupElementTemplate)) {
         // so it gets substitutions for *each* element
         $html = $this->_groupElementTemplate;
     } elseif (method_exists($element, 'getElementTemplateType')) {
         $html = $this->_elementTemplates[$element->getElementTemplateType()];
     } else {
         $html = $this->_elementTemplates['default'];
     }
     if (isset($this->_advancedElements[$element->getName()])) {
         $html = str_replace(' {advanced}', ' advanced', $html);
         $html = str_replace(' {aria-live}', ' aria-live="polite"', $html);
     } else {
         $html = str_replace(' {advanced}', '', $html);
         $html = str_replace(' {aria-live}', '', $html);
     }
     if (isset($this->_advancedElements[$element->getName()]) || $element->getName() == 'mform_showadvanced') {
         $html = str_replace('{advancedimg}', $this->_advancedHTML, $html);
     } else {
         $html = str_replace('{advancedimg}', '', $html);
     }
     $html = str_replace('{id}', 'fitem_' . $element->getAttribute('id'), $html);
     $html = str_replace('{type}', 'f' . $element->getType(), $html);
     $html = str_replace('{name}', $element->getName(), $html);
     $emptylabel = '';
     if ($element->getLabel() == '') {
         $emptylabel = 'femptylabel';
     }
     $html = str_replace('{emptylabel}', $emptylabel, $html);
     if (method_exists($element, 'getHelpButton')) {
         $html = str_replace('{help}', $element->getHelpButton(), $html);
     } else {
         $html = str_replace('{help}', '', $html);
     }
     if ($this->_inGroup and !empty($this->_groupElementTemplate)) {
         $this->_groupElementTemplate = $html;
     } elseif (!isset($this->_templates[$element->getName()])) {
         $this->_templates[$element->getName()] = $html;
     }
     parent::renderElement($element, $required, $error);
 }
Example #2
0
 /**
  * Renders element
  *
  * @param HTML_QuickForm_element $element element
  * @param bool $required if input is required field
  * @param string $error error message to display
  */
 function renderElement(&$element, $required, $error)
 {
     global $OUTPUT;
     // Make sure the element has an id.
     $element->_generateId();
     $advanced = isset($this->_advancedElements[$element->getName()]);
     $html = $OUTPUT->mform_element($element, $required, $advanced, $error, false);
     $fromtemplate = !empty($html);
     if (!$fromtemplate) {
         // Adding stuff to place holders in template
         // check if this is a group element first.
         if ($this->_inGroup and !empty($this->_groupElementTemplate)) {
             // So it gets substitutions for *each* element.
             $html = $this->_groupElementTemplate;
         } else {
             if (method_exists($element, 'getElementTemplateType')) {
                 $html = $this->_elementTemplates[$element->getElementTemplateType()];
             } else {
                 $html = $this->_elementTemplates['default'];
             }
         }
         if (isset($this->_advancedElements[$element->getName()])) {
             $html = str_replace(' {advanced}', ' advanced', $html);
             $html = str_replace(' {aria-live}', ' aria-live="polite"', $html);
         } else {
             $html = str_replace(' {advanced}', '', $html);
             $html = str_replace(' {aria-live}', '', $html);
         }
         if (isset($this->_advancedElements[$element->getName()]) || $element->getName() == 'mform_showadvanced') {
             $html = str_replace('{advancedimg}', $this->_advancedHTML, $html);
         } else {
             $html = str_replace('{advancedimg}', '', $html);
         }
         $html = str_replace('{id}', 'fitem_' . $element->getAttribute('id'), $html);
         $html = str_replace('{typeclass}', 'f' . $element->getType(), $html);
         $html = str_replace('{type}', $element->getType(), $html);
         $html = str_replace('{name}', $element->getName(), $html);
         $html = str_replace('{class}', $element->getAttribute('class'), $html);
         $emptylabel = '';
         if ($element->getLabel() == '') {
             $emptylabel = 'femptylabel';
         }
         $html = str_replace('{emptylabel}', $emptylabel, $html);
         if (method_exists($element, 'getHelpButton')) {
             $html = str_replace('{help}', $element->getHelpButton(), $html);
         } else {
             $html = str_replace('{help}', '', $html);
         }
     } else {
         if ($this->_inGroup) {
             $this->_groupElementTemplate = $html;
         }
     }
     if ($this->_inGroup and !empty($this->_groupElementTemplate)) {
         $this->_groupElementTemplate = $html;
     } else {
         if (!isset($this->_templates[$element->getName()])) {
             $this->_templates[$element->getName()] = $html;
         }
     }
     if (!$fromtemplate) {
         parent::renderElement($element, $required, $error);
     } else {
         if (in_array($element->getName(), $this->_stopFieldsetElements) && $this->_fieldsetsOpen > 0) {
             $this->_html .= $this->_closeFieldsetTemplate;
             $this->_fieldsetsOpen--;
         }
         $this->_html .= $html;
     }
 }