当前位置: 首页>>代码示例>>PHP>>正文


PHP JForm::validate方法代码示例

本文整理汇总了PHP中JForm::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP JForm::validate方法的具体用法?PHP JForm::validate怎么用?PHP JForm::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JForm的用法示例。


在下文中一共展示了JForm::validate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validate

 /**
  * 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
  * @since   12.2
  */
 public function validate($form, $data, $group = null)
 {
     // Filter and validate the form data.
     $data = $form->filter($data);
     $return = $form->validate($data, $group);
     // Check for an error.
     if ($return instanceof Exception) {
         $this->setError($return->getMessage());
         return false;
     }
     // Check the validation results.
     if ($return === false) {
         // Get the validation messages from the form.
         foreach ($form->getErrors() as $message) {
             $this->setError($message);
         }
         return false;
     }
     return $data;
 }
开发者ID:RuDers,项目名称:JoomlaSQL,代码行数:33,代码来源:form.php

示例2: validate

 /**
  * Method to validate the form data.
  * Each field error is stored in session and can be retrieved with getFieldError().
  * Once getFieldError() is called, the error is deleted from the session.
  *
  * @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.
  */
 public function validate($form, $data, $group = null)
 {
     // Filter and validate the form data.
     $data = $form->filter($data);
     $return = $form->validate($data, $group);
     // Check for an error.
     if ($return instanceof Exception) {
         $this->setError($return->getMessage());
         return false;
     }
     // Check the validation results.
     if ($return === false) {
         $session = JFactory::getSession();
         // Get the validation messages from the form.
         foreach ($form->getErrors() as $key => $message) {
             $this->setError($message);
             if ($message instanceof Exception) {
                 // Store the field error in session.
                 $session->set($this->context . '.error.' . $key, $message->getMessage());
             } else {
                 // Store the field error in session.
                 $session->set($this->context . '.error.' . $key, $message);
             }
         }
         return false;
     }
     return $data;
 }
开发者ID:prox91,项目名称:joomla-dev,代码行数:39,代码来源:base.php

示例3: onExtensionBeforeSave

 function onExtensionBeforeSave($context, $table, $isNew)
 {
     // *******************************
     // TODO: add support for com_menus
     // *******************************
     // Check for com_modules context
     if ($context == 'com_modules.module' || $context == 'com_advancedmodules.module' || substr($context, 0, 10) === "com_falang") {
         // Check for non-empty layout parameter
         $layout = $_POST['jform']['params']['layout'];
         if (empty($layout)) {
             return;
         }
         // Check for currently supported cases, !!! TODO add case of MENUS
         if (empty($table->module)) {
             return;
         }
         // Check if layout XML parameter file exists
         $client = JApplicationHelper::getClientInfo($table->client_id);
         $layoutpath = JPath::clean($client->path . '/modules/' . $table->module . '/tmpl/' . $layout . '.xml');
         if (!file_exists($layoutpath)) {
             $layoutpath = JPath::clean($client->path . '/modules/' . $table->module . '/tmpl/_fallback/_fallback.xml');
             if (!file_exists($layoutpath)) {
                 return;
             }
         }
         // Load XML file
         if (FLEXI_J30GE) {
             $xml = simplexml_load_file($layoutpath);
             $xmldoc =& $xml;
         } else {
             $xml = JFactory::getXMLParser('Simple');
             $xml->loadFile($layoutpath);
             $xmldoc =& $xml->document;
         }
         //echo "<pre>"; print_r($xmldoc); echo "</pre>";
         // Create form object loading the , (form name seems not to cause any problem)
         $jform = new JForm('com_flexicontent.template.item', array('control' => 'jform', 'load_data' => true));
         $tmpl_params = FLEXI_J30GE ? $xmldoc->asXML() : $xmldoc->toString();
         $jform->load($tmpl_params);
         // Set cleared layout parameters
         $_post =& $_POST['jform']['params'];
         //echo "<pre>"; print_r($_post); echo "</pre>";
         $params = new JRegistry($table->params);
         $grpname = 'params';
         $isValid = !$jform->validate($_post, $grpname);
         if ($isValid) {
             JFactory::getApplication()->enqueueMessage('Error validating layout posted parameters. Layout parameters were not saved', 'error');
             return;
         }
         foreach ($jform->getGroup($grpname) as $field) {
             $fieldname = $field->__get('fieldname');
             if (substr($fieldname, 0, 2) == "__") {
                 continue;
             }
             $value = $_post[$fieldname];
             $params->set($fieldname, $value);
         }
         // Set parameters back to module's DB table object
         $table->params = $params->toString();
         //echo "<pre>"; print_r($table->params); echo "</pre>";
         //die('onExtensionBeforeSave: '. $layoutpath);
     }
 }
开发者ID:khetsothea,项目名称:flexicontent-cck,代码行数:63,代码来源:flexisystem.php

示例4: validate

 /**
  * 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  array|boolean  Array of filtered data if valid, false otherwise.
  *
  * @see     JFormRule
  * @see     JFilterInput
  * @since   12.2
  */
 public function validate($form, $data, $group = null)
 {
     // Include the plugins for the delete events.
     JPluginHelper::importPlugin($this->events_map['validate']);
     $dispatcher = JEventDispatcher::getInstance();
     $dispatcher->trigger('onUserBeforeDataValidation', array($form, &$data));
     // Filter and validate the form data.
     $data = $form->filter($data);
     $return = $form->validate($data, $group);
     // Check for an error.
     if ($return instanceof Exception) {
         $this->setError($return->getMessage());
         return false;
     }
     // Check the validation results.
     if ($return === false) {
         // Get the validation messages from the form.
         foreach ($form->getErrors() as $message) {
             $this->setError($message);
         }
         return false;
     }
     // Tags B/C break at 3.1.2
     if (isset($data['metadata']['tags']) && !isset($data['tags'])) {
         $data['tags'] = $data['metadata']['tags'];
     }
     return $data;
 }
开发者ID:eshiol,项目名称:joomla-cms,代码行数:41,代码来源:form.php

示例5: validate

 /**
  * 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
  * @since   3.2
  */
 public function validate($form, $data, $group = null)
 {
     // Filter and validate the form data.
     $data = $form->filter($data);
     $return = $form->validate($data, $group);
     // Check for an error.
     if ($return instanceof Exception) {
         JFactory::getApplication()->enqueueMessage($return->getMessage(), 'error');
         return false;
     }
     // Check the validation results.
     if ($return === false) {
         // Get the validation messages from the form.
         foreach ($form->getErrors() as $message) {
             if ($message instanceof Exception) {
                 $message = $message->getMessage();
             }
             JFactory::getApplication()->enqueueMessage($message, 'error');
         }
         return false;
     }
     return $data;
 }
开发者ID:SysBind,项目名称:joomla-cms,代码行数:36,代码来源:form.php

示例6: validateForm

	/**
	 * Method to validate the permissions 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 array|string    Array of filtered data if valid, string with error otherwise.
	 */
	protected static function validateForm( $form, $data, $group = null )
	{
		$data				=	$form->filter( $data );
		$return				=	$form->validate( $data, $group );

		if ( $return instanceof \Exception ) {
			/** @var $return \Exception */
			return $return->getMessage();
		}

		if ( $return === false ) {
			$errors			=	array();
			foreach ( $form->getErrors() as $message ) {
				$errors[]	=	\JText::_($message);
			}
			return implode( "\n", $errors );
		}

		return $data;
	}
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:28,代码来源:RegistryEditView.php

示例7: validate

 /**
  * 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.
  *
  * @throws  ValidateFailException
  * @throws  \Exception
  * @return  mixed  Array of filtered data if valid, false otherwise.
  *
  * @see     JFormRule
  * @see     JFilterInput
  */
 public function validate($form, $data, $group = null)
 {
     // Filter and validate the form data.
     /** @var $form \JForm */
     $data = $form->filter($data);
     $return = $form->validate($data, $group);
     // Check for an error.
     if ($return instanceof \Exception) {
         throw $return;
     }
     // Check the validation results.
     if ($return === false) {
         // Get the validation messages from the form.
         throw new ValidateFailException($form->getErrors());
     }
     return $data;
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:31,代码来源:AbstractFormModel.php

示例8: validate

 /**
  * 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
  * @since   12.2
  */
 public function validate($form, $data, $group = null)
 {
     // Filter and validate the form data.
     $data = $form->filter($data);
     $return = $form->validate($data, $group);
     // Check for an error.
     if ($return instanceof Exception) {
         $this->setError($return->getMessage());
         return false;
     }
     // Check the validation results.
     if ($return === false) {
         // Get the validation messages from the form.
         foreach ($form->getErrors() as $message) {
             $this->setError($message);
         }
         return false;
     }
     $config = JFactory::getConfig();
     $tzoffset = $config->get('offset');
     if (isset($data['order_date']) && $data['order_date']) {
         $date = JFactory::getDate($data['order_date']);
         $purchase_date = $date->toSql();
         $order_date = $date->toUNIX();
     } else {
         $purchase_date = date('Y-m-d H:i:s', time() + $tzoffset);
         $date = JFactory::getDate();
         $order_date = $date->toUNIX();
     }
     $data['order_date'] = $order_date;
     $data['promocodediscount'] = $data['discount'];
     $data['promocodeid'] = $this->getPromocodeByCode($data['discount']);
     $data['number_of_products'] = count($data['product_id']);
     $data['published'] = '1';
     return $data;
 }
开发者ID:Shtier,项目名称:digicom,代码行数:49,代码来源:ordernew.php


注:本文中的JForm::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。