本文整理汇总了PHP中JModelForm::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP JModelForm::validate方法的具体用法?PHP JModelForm::validate怎么用?PHP JModelForm::validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JModelForm
的用法示例。
在下文中一共展示了JModelForm::validate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testValidatePassesDataAndGroupToJform
/**
* Test JModelForm::validate
*
* @since 3.4
*
* @return void
*
* @testdox validate() passes data and group to JForm
*/
public function testValidatePassesDataAndGroupToJform()
{
$data = array("a" => "b");
$group = "groupy";
$formMock = $this->getMockBuilder('JForm')->disableOriginalConstructor()->getMock();
$formMock->expects($this->once())->method('validate')->with($data, $group)->willReturn(true);
$formMock->expects($this->once())->method('filter')->with($data)->will($this->returnArgument(0));
$this->object->validate($formMock, $data, $group);
}
示例2: validate
/**
* 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)
{
$return = parent::validate($form, $data);
if (!$return) {
return false;
}
// //Check xem da ton tai dich vu loai nay chua
// $category = $data['category'];
// $id = $data['id'];
// if($id == 0) {
// $db = JFactory::getDbo();
// $db->setQuery(
// 'SELECT * FROM #__hp_business_service WHERE category = '.(int)$category
// );
// if($db->loadObject()) {
// $this->setError('Bạn đã có dịch vụ này!');
// $return = false;
// }
// }
//
return $return;
}
示例3: validate
/**
* Method to validate the form data.
*
* @access public
* @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.
*/
public function validate($form, $data)
{
$this->_setAccessFilters($form, $data);
return parent::validate($form, $data);
}
示例4: validate
public function validate($form, $data, $group = null)
{
// error_log("in AkrecipesModelRecipeForm::validate --> form --> ");
// $e = new Exception;
// error_log(print_r($e->getTraceAsString(),true));
$jinput = JFactory::getApplication()->input;
$uploaded_image = $jinput->files->get('jform')['image'];
error_log("validate --> uploaded_image name --> " . print_r($uploaded_image, true));
//error_log("Image name --> " . $uploaded_image['name']);
require_once JPATH_COMPONENT_ADMINISTRATOR . '/lib/class.upload.php';
$handle = new Upload($uploaded_image);
$handle->allowed = array('image/*');
if ($handle->uploaded) {
error_log("Image mime type = " . $handle->file_src_mime);
if (strpos($handle->file_src_mime, 'image/') !== 0) {
error_log("Uploaded file is not an image. Please upload an image.");
$this->setError("Uploaded file is not an image. Please upload an image.");
return false;
}
}
//return true;
return parent::validate($form, $data, $group);
}
示例5: validate
/**
* Validate the submitted configuration data.
*
* The <b>save</b> method of this class automatically calls this method
* before saving configuration data to database. So, you <b>DO NOT NEED</b>
* to call this method manually.
*
* @param array $config Parsed XML config declaration.
* @param array $data The data to validate.
* @param string $group The name of the field group to validate.
*
* @return void
*/
public function validate($config, $data, $group = null)
{
// Get input object
$input = JFactory::getApplication()->input;
// Get keys for first section and group
$key = array_keys($config);
$fSection = array_shift($key);
$key = array_keys($config[$fSection]->groups);
$fGroup = array_shift($key);
// Get requested section and group keys
$rSection = $input->getCmd('s', $fSection);
$rGroup = $input->getCmd('g', $fGroup);
// Validate config data
if (!isset($config[$rSection]->groups[$rGroup]->tabs)) {
$config[$rSection]->groups[$rGroup]->tabs[] = (object) array('fieldsets' => $config[$rSection]->groups[$rGroup]->fieldsets);
}
foreach ($config[$rSection]->groups[$rGroup]->tabs as $tab) {
foreach ($tab->fieldsets as $fieldset) {
if (isset($fieldset->form) and count($fieldset->form->getFieldset())) {
$return = parent::validate($fieldset->form, $data);
if ($return === false) {
throw new Exception(JText::_('JSN_EXTFW_CONFIG_VALIDATION_FAIL'));
}
}
}
}
}