Example #1
0
 /**
  * Renders a F0FForm for an Edit view and returns the corresponding HTML
  *
  * @param   F0FForm   &$form  The form to render
  * @param   F0FModel  $model  The model providing our data
  * @param   F0FInput  $input  The input object
  *
  * @return  string    The HTML rendering of the form
  */
 protected function renderFormEdit(F0FForm &$form, F0FModel $model, F0FInput $input)
 {
     // Get the key for this model's table
     $key = $model->getTable()->getKeyName();
     $keyValue = $model->getId();
     JHTML::_('behavior.tooltip');
     $html = '';
     $validate = strtolower($form->getAttribute('validate'));
     $class = '';
     if (in_array($validate, array('true', 'yes', '1', 'on'))) {
         JHtml::_('behavior.formvalidation');
         $class = 'form-validate ';
         $this->loadValidationScript($form);
     }
     // Check form enctype. Use enctype="multipart/form-data" to upload binary files in your form.
     $template_form_enctype = $form->getAttribute('enctype');
     if (!empty($template_form_enctype)) {
         $enctype = ' enctype="' . $form->getAttribute('enctype') . '" ';
     } else {
         $enctype = '';
     }
     // Check form name. Use name="yourformname" to modify the name of your form.
     $formname = $form->getAttribute('name');
     if (empty($formname)) {
         $formname = 'adminForm';
     }
     // Check form ID. Use id="yourformname" to modify the id of your form.
     $formid = $form->getAttribute('name');
     if (empty($formid)) {
         $formid = 'adminForm';
     }
     // Check if we have a custom task
     $customTask = $form->getAttribute('customTask');
     if (empty($customTask)) {
         $customTask = '';
     }
     // Get the form action URL
     $actionUrl = F0FPlatform::getInstance()->isBackend() ? 'index.php' : JUri::root() . 'index.php';
     if (F0FPlatform::getInstance()->isFrontend() && $input->getCmd('Itemid', 0) != 0) {
         $itemid = $input->getCmd('Itemid', 0);
         $uri = new JUri($actionUrl);
         if ($itemid) {
             $uri->setVar('Itemid', $itemid);
         }
         $actionUrl = JRoute::_($uri->toString());
     }
     $html .= '<form action="' . $actionUrl . '" method="post" name="' . $formname . '" id="' . $formid . '"' . $enctype . ' class="' . $class . '">' . PHP_EOL;
     $html .= "\t" . '<input type="hidden" name="option" value="' . $input->getCmd('option') . '" />' . PHP_EOL;
     $html .= "\t" . '<input type="hidden" name="view" value="' . $input->getCmd('view', 'edit') . '" />' . PHP_EOL;
     $html .= "\t" . '<input type="hidden" name="task" value="' . $customTask . '" />' . PHP_EOL;
     $html .= "\t" . '<input type="hidden" name="' . $key . '" value="' . $keyValue . '" />' . PHP_EOL;
     $html .= "\t" . '<input type="hidden" name="' . JFactory::getSession()->getFormToken() . '" value="1" />' . PHP_EOL;
     $html .= $this->renderFormRaw($form, $model, $input, 'edit');
     $html .= '</form>';
     return $html;
 }
Example #2
0
 /**
  * Renders a F0FForm for an Edit view and returns the corresponding HTML
  *
  * @param   F0FForm   &$form  The form to render
  * @param   F0FModel  $model  The model providing our data
  * @param   F0FInput  $input  The input object
  *
  * @return  string    The HTML rendering of the form
  */
 protected function renderFormEdit(F0FForm &$form, F0FModel $model, F0FInput $input)
 {
     // Get the key for this model's table
     $key = $model->getTable()->getKeyName();
     $keyValue = $model->getId();
     $html = '';
     $validate = strtolower($form->getAttribute('validate'));
     if (in_array($validate, array('true', 'yes', '1', 'on'))) {
         JHTML::_('behavior.framework', true);
         JHTML::_('behavior.formvalidation');
         $class = ' form-validate';
         $this->loadValidationScript($form);
     } else {
         $class = '';
     }
     // Check form enctype. Use enctype="multipart/form-data" to upload binary files in your form.
     $template_form_enctype = $form->getAttribute('enctype');
     if (!empty($template_form_enctype)) {
         $enctype = ' enctype="' . $form->getAttribute('enctype') . '" ';
     } else {
         $enctype = '';
     }
     // Check form name. Use name="yourformname" to modify the name of your form.
     $formname = $form->getAttribute('name');
     if (empty($formname)) {
         $formname = 'adminForm';
     }
     // Check form ID. Use id="yourformname" to modify the id of your form.
     $formid = $form->getAttribute('name');
     if (empty($formid)) {
         $formid = 'adminForm';
     }
     $html .= '<form action="index.php" method="post" name="' . $formname . '" id="' . $formid . '"' . $enctype . ' class="form-horizontal' . $class . '">' . PHP_EOL;
     $html .= "\t" . '<input type="hidden" name="option" value="' . $input->getCmd('option') . '" />' . PHP_EOL;
     $html .= "\t" . '<input type="hidden" name="view" value="' . $input->getCmd('view', 'edit') . '" />' . PHP_EOL;
     $html .= "\t" . '<input type="hidden" name="task" value="" />' . PHP_EOL;
     $html .= "\t" . '<input type="hidden" name="' . $key . '" value="' . $keyValue . '" />' . PHP_EOL;
     if (F0FPlatform::getInstance()->isFrontend() && $input->getCmd('Itemid', 0) != 0) {
         $html .= "\t" . '<input type="hidden" name="Itemid" value="' . $input->getCmd('Itemid', 0) . '" />' . PHP_EOL;
     }
     $html .= "\t" . '<input type="hidden" name="' . JFactory::getSession()->getFormToken() . '" value="1" />' . PHP_EOL;
     $html .= $this->renderFormRaw($form, $model, $input, 'edit');
     $html .= '</form>';
     return $html;
 }