Development

#2932: date_format_exception.patch

You must first sign up to be able to contribute.

Ticket #2932: date_format_exception.patch

File date_format_exception.patch, 3.7 kB (added by manickam, 1 year ago)

Patch for Date format exception handling

  • lib/exception/sfFieldException.class.php

    old new  
     1<?php  
     2 
     3class sfFieldException extends sfException 
     4{ 
     5      protected $field; 
     6 
     7      function setField( $fld) 
     8      { 
     9        $this->field = $fld; 
     10      } 
     11 
     12      function getField() 
     13      { 
     14        return $this->field; 
     15      } 
     16 
     17      public function __construct( $message, $code = 0, $field = 'generic') 
     18      { 
     19        parent::__construct( $message, $code ); 
     20        $this->field = $field; 
     21      } 
     22} 
     23 
     24?> 
     25 
  • lib/plugins/sfPropelPlugin/data/generator/sfPropelAdmin/default/template/actions/actions.class.php

    old new  
    4949 
    5050  public function executeSave() 
    5151  { 
    52     return $this->forward('<?php echo $this->getModuleName() ?>', 'edit'); 
     52    try { 
     53          return $this->forward('<?php echo $this->getModuleName() ?>', 'edit'); 
     54    } 
     55    catch( sfStopException $e ) { 
     56          throw $e; 
     57    } 
     58    catch( sfFieldException $e) { 
     59          $this->getRequest()->setError( $e->getField(), $e->getMessage() ); 
     60    } 
     61    catch( Exception $e) { 
     62          $this->getRequest()->setError( "generic", $e->getMessage() ); 
     63    } 
     64    $this->getRequest()->setMethod( sfRequest::GET ); 
     65    $this->forward('<?php echo $this->getModuleName() ?>', 'edit'); 
     66 
    5367  } 
    5468 
    5569<?php $listActions = $this->getParameterValue('list.batch_actions') ?> 
     
    105119  { 
    106120    $this-><?php echo $this->getSingularName() ?> = $this->get<?php echo $this->getClassName() ?>OrCreate(); 
    107121 
    108     if ($this->getRequest()->isMethod('post')
     122    if ($this->getRequest()->getMethod() == sfRequest::POST
    109123    { 
    110124      $this->update<?php echo $this->getClassName() ?>FromRequest(); 
    111125 
     
    166180 
    167181  public function handleErrorEdit() 
    168182  { 
    169     $this->preExecute(); 
    170     $this-><?php echo $this->getSingularName() ?> = $this->get<?php echo $this->getClassName() ?>OrCreate(); 
    171     $this->update<?php echo $this->getClassName() ?>FromRequest(); 
     183    try { 
     184      $this->preExecute(); 
     185      $this-><?php echo $this->getSingularName() ?> = $this->get<?php echo $this->getClassName() ?>OrCreate(); 
     186      $this->update<?php echo $this->getClassName() ?>FromRequest(); 
    172187 
    173     $this->labels = $this->getLabels(); 
     188      $this->labels = $this->getLabels(); 
     189    } catch( sfStopException $e ) { 
     190        throw $e; 
     191    } catch( sfFieldException $e) { 
     192        $this->getRequest()->setError( $e->getField(), $e->getMessage() ); 
     193    } catch ( Exception $e ) { 
     194        $this->getRequest()->setError( "generic", $e->getMessage() ); 
     195    } 
    174196 
    175197    return sfView::SUCCESS; 
     198       
    176199  } 
    177200 
    178201  protected function save<?php echo $this->getClassName() ?>($<?php echo $this->getSingularName() ?>) 
     
    308331        catch (sfException $e) 
    309332        { 
    310333          // not a date 
     334           $this->logMessage("{sfAction} <?php echo $column->getPhpName() ?> : ".$e->getMessage(), "info" ); 
     335           $ex = new sfFieldException( $e->getMessage(), 0, "<?php echo $this->getSingularName() ?>{<?php echo $name ?>}" ); 
     336           throw $ex; 
    311337        } 
    312338      } 
    313339      else