Exemple #1
0
 /**
  * When saving a list that links to a database for the first time we
  * automatically create a form to allow the update/creation of that tables
  * records
  *
  * @param   int $formId to copy from. If = 0 then create a default form. If not 0 then copy the form id passed in
  *
  * @return  object  form model
  */
 private function createLinkedForm($formId = 0)
 {
     $this->getFormModel();
     if ($formId == 0) {
         /**
          * $$$ rob required otherwise the JTable is loaed with db_table_name as a property
          * which then generates an error - not sure why its loaded like that though?
          * 18/08/2011 - could be due to the Form table class having it in its bind method
          * - (have now overridden form table store() to remove thoes two params)
          */
         $this->formModel->getForm();
         jimport('joomla.utilities.date');
         $createDate = JFactory::getDate();
         $createDate = $createDate->toSql();
         $form = $this->getTable('Form');
         $item = $this->getTable('List');
         $defaults = FabrikWorker::formDefaults('form');
         $form->bind($defaults);
         $form->set('label', $item->get('label'));
         $form->set('record_in_database', 1);
         $form->set('created', $createDate);
         $form->set('created_by', $this->user->get('id'));
         $form->set('created_by_alias', $this->user->get('username'));
         $form->set('error', FText::_('COM_FABRIK_FORM_ERROR_MSG_TEXT'));
         $form->set('submit_button_label', FText::_('COM_FABRIK_SAVE'));
         $form->set('published', $item->get('published'));
         $version = new JVersion();
         $form->set('form_template', version_compare($version->RELEASE, '3.0') >= 0 ? 'bootstrap' : 'default');
         $form->set('view_only_template', version_compare($version->RELEASE, '3.0') >= 0 ? 'bootstrap' : 'default');
         $form->store();
         $this->setState('list.form_id', $form->get('id'));
         $this->formModel->setId($form->get('id'));
     } else {
         $this->setState('list.form_id', $formId);
         $this->formModel->setId($formId);
         $this->formModel->getTable();
         $this->formModel->copy();
     }
     $this->formModel->getForm();
     return $this->formModel;
 }
Exemple #2
0
 /**
  * When saving a list that links to a database for the first time we
  * automatically create a form to allow the update/creation of that tables
  * records
  *
  * @param   int  $formid  to copy from. If = 0 then create a default form. If not 0 then copy the form id passed in
  *
  * @return  object  form model
  */
 private function createLinkedForm($formid = 0)
 {
     $config = JFactory::getConfig();
     $user = JFactory::getUser();
     $this->getFormModel();
     if ($formid == 0) {
         /**
          * $$$ rob required otherwise the JTable is loaed with db_table_name as a property
          * which then generates an error - not sure why its loaded like that though?
          * 18/08/2011 - could be due to the Form table class having it in its bind method
          * - (have now overridden form table store() to remove thoes two params)
          */
         $this->formModel->getForm();
         jimport('joomla.utilities.date');
         $createdate = JFactory::getDate();
         $createdate = $createdate->toSql();
         $form = $this->getTable('Form');
         $item = $this->getTable('List');
         $defaults = FabrikWorker::formDefaults('form');
         $form->bind($defaults);
         $form->label = $item->label;
         $form->record_in_database = 1;
         $form->created = $createdate;
         $form->created_by = $user->get('id');
         $form->created_by_alias = $user->get('username');
         $form->error = JText::_('COM_FABRIK_FORM_ERROR_MSG_TEXT');
         $form->submit_button_label = JText::_('COM_FABRIK_SAVE');
         $form->published = $item->published;
         $form->form_template = 'default';
         $form->view_only_template = 'default';
         if (!$form->store()) {
             return JError::raiseError(500, $form->getError());
         }
         $this->setState('list.form_id', $form->id);
         $this->formModel->setId($form->id);
     } else {
         $this->setState('list.form_id', $formid);
         $this->formModel->setId($formid);
         $this->formModel->getTable();
         if (!$this->formModel->copy()) {
             return JError::raiseError(500, $form->getError());
         }
     }
     $this->formModel->getForm();
     return $this->formModel;
 }