[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 3 /* 4 * This file is part of the symfony package. 5 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 6 * 7 * For the full copyright and license information, please view the LICENSE 8 * file that was distributed with this source code. 9 */ 10 11 /** 12 * ValidationHelper. 13 * 14 * @package symfony 15 * @subpackage helper 16 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 17 * @version SVN: $Id: ValidationHelper.php 1553 2006-06-29 19:26:04Z fabien $ 18 */ 19 20 function form_has_error($param) 21 { 22 return sfContext::getInstance()->getRequest()->hasError($param); 23 } 24 25 function form_error($param, $options = array(), $catalogue = 'messages') 26 { 27 $param_for_sf = str_replace(array('[', ']'), array('{', '}'), $param); 28 $param = str_replace(array('{', '}'), array('[', ']'), $param); 29 30 $options = _parse_attributes($options); 31 32 $request = sfContext::getInstance()->getRequest(); 33 34 $style = $request->hasError($param_for_sf) ? '' : 'display:none;'; 35 $options['style'] = $style.(isset($options['style']) ? $options['style']:''); 36 37 if (!isset($options['class'])) 38 { 39 $options['class'] = sfConfig::get('sf_validation_error_class', 'form_error'); 40 } 41 if (!isset($options['id'])) 42 { 43 $options['id'] = sfConfig::get('sf_validation_error_id_prefix', 'error_for_').get_id_from_name($param); 44 } 45 46 $prefix = sfConfig::get('sf_validation_error_prefix', ''); 47 if (isset($options['prefix'])) 48 { 49 $prefix = $options['prefix']; 50 unset($options['prefix']); 51 } 52 53 $suffix = sfConfig::get('sf_validation_error_suffix', ''); 54 if (isset($options['suffix'])) 55 { 56 $suffix = $options['suffix']; 57 unset($options['suffix']); 58 } 59 60 $error = $request->getError($param_for_sf, $catalogue); 61 62 return content_tag('div', $prefix.$error.$suffix, $options)."\n"; 63 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |