/** * Validate the form * * @param JForm $form The form to validate against. * @param array $data The data to validate. * @param string $group The name of the field group to validate. * * @return mixed false or data */ public function validate($form, $data, $group = null) { $params = $data['params']; $data = parent::validate($form, $data, $group); if (!$data) { return false; } if (empty($data['_database_name']) && FArrayHelper::getValue($data, 'db_table_name') == '') { $this->setError(FText::_('COM_FABRIK_SELECT_DB_OR_ENTER_NAME')); return false; } // Hack - must be able to add the plugin xml fields file to $form to include in validation but cant see how at the moment $data['params'] = $params; return $data; }
/** * Method to validate the form data. * * @param object $form The form to validate against. * @param array $data The data to validate. * @return mixed Array of filtered data if valid, false otherwise. * @since 1.1 */ function validate($form, $data) { $params = $data['params']; $ok = parent::validate($form, $data); //standard jform validation failed so we shouldn't test further as we can't //be sure of the data if (!$ok) { return false; } //hack - must be able to add the plugin xml fields file to $form to include in validation // but cant see how at the moment $data['params'] = $params; return $data; }
/** * Method to validate the form data. * * @param JForm $form The form to validate against. * @param array $data The data to validate. * @param string $group The name of the field group to validate. * * @see JFormRule * @see JFilterInput * * @return mixed Array of filtered data if valid, false otherwise. */ public function validate($form, $data, $group = null) { if ($data['password'] !== $data['passwordConf']) { $this->setError(FText::_('COM_FABRIK_PASSWORD_MISMATCH')); return false; } return parent::validate($form, $data); }
/** * Method to validate the form data. * * @param JForm $form The form to validate against. * @param array $data The data to validate. * @param string $group The name of the field group to validate. * * @see JFormRule * @see JFilterInput * * @return mixed Array of filtered data if valid, false otherwise. */ public function validate($form, $data, $group = null) { $ok = parent::validate($form, $data); $input = $this->app->input; // Standard jform validation failed so we shouldn't test further as we can't be sure of the data if (!$ok) { return false; } $db = FabrikWorker::getDbo(true); $elementModel = $this->getElementPluginModel($data); $nameChanged = $data['name'] !== $elementModel->getElement()->name; $elementModel->getElement()->bind($data); $listModel = $elementModel->getListModel(); if ($data['id'] == '') { // Have to forcefully set group id otherwise listmodel id is blank $elementModel->getElement()->group_id = $data['group_id']; if ($listModel->canAddFields() === false && $listModel->noTable() === false) { $this->setError(FText::_('COM_FABRIK_ERR_CANT_ADD_FIELDS')); } if (FabrikWorker::isReserved($data['name'])) { $this->setError(FText::_('COM_FABRIK_RESERVED_NAME_USED')); } } else { if ($listModel->canAlterFields() === false && $nameChanged && $listModel->noTable() === false) { $this->setError(FText::_('COM_FABRIK_ERR_CANT_ALTER_EXISTING_FIELDS')); } if ($nameChanged && FabrikWorker::isReserved($data['name'], false)) { $this->setError(FText::_('COM_FABRIK_RESERVED_NAME_USED')); } } $listModel = $elementModel->getListModel(); /** * Test for duplicate names * unlinking produces this error */ if (!$input->get('unlink', false) && (int) $data['id'] === 0) { $query = $db->getQuery(true); $query->select('t.id')->from('#__{package}_joins AS j'); $query->join('INNER', '#__{package}_lists AS t ON j.table_join = t.db_table_name'); $query->where('group_id = ' . (int) $data['group_id'] . ' AND element_id = 0'); $db->setQuery($query); $joinTblId = (int) $db->loadResult(); $ignore = array($data['id']); if ($joinTblId === 0) { if ($listModel->fieldExists($data['name'], $ignore)) { $this->setError(FText::_('COM_FABRIK_ELEMENT_NAME_IN_USE')); } } else { $joinListModel = JModelLegacy::getInstance('list', 'FabrikFEModel'); $joinListModel->setId($joinTblId); $joinEls = $joinListModel->getElements(); foreach ($joinEls as $joinEl) { if ($joinEl->getElement()->name == $data['name']) { $ignore[] = $joinEl->getElement()->id; } } if ($joinListModel->fieldExists($data['name'], $ignore)) { $this->setError(FText::_('COM_FABRIK_ELEMENT_NAME_IN_USE')); } } } // Strip <p> tag from label $data['label'] = JString::str_ireplace(array('<p>', '</p>'), '', $data['label']); return count($this->getErrors()) == 0 ? $data : false; }
/** * Method to validate the form data. * * @param JForm $form The form to validate against. * @param array $data The data to validate. * @param string $group The name of the field group to validate. * * @return mixed Array of filtered data if valid, false otherwise. * * @see JFormRule * @see JFilterInput */ public function validate($form, $data, $group = null) { parent::validate($form, $data); return $data; }