/** * Batch copy fields to new forms. * * @param int $pk form id of original form that is to be copied * @param int $newId form id of new form * @param array $contexts An array of forms contexts. * * @return mixed An array of new IDs on success, boolean false on failure. * * @since 11.1 */ protected function batchCopyFields($pk, $newId, $contexts) { $fieldsModel = new VisformsModelVisfield(); $fieldsTable = $fieldsModel->getTable(); $db = JFactory::getDbo(); $query = $db->getQuery(true); //Select Ids of Fields of copied form in Table visfields $query->select('a.id')->from('#__visfields AS a')->where('a.fid = ' . $pk); $db->setQuery($query); $results = $db->loadColumn(); $fieldsModel->batch(array('form_id' => $newId, 'unpublish' => false), $results, $contexts); // Clean the cache $this->cleanCache(); }