×

Welcome to TagMyCode

Please login or create account to add a snippet.
1
0
 
2
Language: PHP
Posted by: Mike Harvey
Added: Nov 6, 2015 2:11 PM
Views: 1927
Tags: cmp modx
  1. <?php
  2. /**
  3.  * @package sample
  4.  * @subpackage processors
  5.  */
  6. class SampleCreateProcessor extends modObjectCreateProcessor {
  7.     public $classKey = 'rtSample';
  8.     public $languageTopics = array('recroot:default');
  9.     public $objectType = 'sample.user';
  10.  
  11.     public function beforeSave() {
  12.         $lastname = $this->getProperty('lastname'); if (empty($lastname)) {$this->addFieldError('lastname',$this->modx->lexicon('sample.user_err_ns_lastname'));}
  13.         $firstname = $this->getProperty('firstname'); if (empty($firstname)) {$this->addFieldError('firstname',$this->modx->lexicon('sample.user_err_ns_firstname'));}
  14.         $email = $this->getProperty('email'); if (empty($email)) {$this->addFieldError('email',$this->modx->lexicon('sample.user_err_ns_email'));}
  15.         $home_phone = $this->getProperty('home_phone'); if (empty($home_phone)) {$this->addFieldError('home_phone',$this->modx->lexicon('sample.user_err_ns_home_phone'));}
  16.         $address = $this->getProperty('address'); if (empty($address)) {$this->addFieldError('address',$this->modx->lexicon('sample.user_err_ns_address'));}
  17.         $city = $this->getProperty('city'); if (empty($city)) {$this->addFieldError('city',$this->modx->lexicon('sample.user_err_ns_city'));}
  18.         $state = $this->getProperty('state'); if (empty($state)) {$this->addFieldError('state',$this->modx->lexicon('sample.user_err_ns_state'));}
  19.         $zip = $this->getProperty('zip'); if (empty($zip)) {$this->addFieldError('zip',$this->modx->lexicon('sample.user_err_ns_zip'));}
  20.        
  21.         return parent::beforeSave();
  22.     }
  23. }
  24. return 'SampleCreateProcessor';

1 comment

Mike Harvey 7 years ago
My first posted snippet.

Write a comment