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


PHP JForm::getErrors方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例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  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

示例5: 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

示例6: 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

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