[ Index ]

MailPress 7.1

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/class/options/form/field_types/ereg/ -> ereg.php (source)

   1  <?php
   2  class MP_Form_field_type_ereg extends MP_form_field_type_
   3  {
   4      var $file        = __FILE__;
   5  
   6      var $id        = 'ereg';
   7  
   8      var $category     = 'html';
   9  
  10      var $order        = 90;
  11  
  12  	function submitted( $field )
  13      {
  14          $this->field = $field;
  15  
  16          $value    = $this->get_value();
  17          $value    = trim( $value );
  18  
  19          $required     = ( isset( $this->field->settings['controls']['required'] ) && $this->field->settings['controls']['required'] );
  20          $empty     = empty( $value );
  21          $ereg_ok     = true;
  22  
  23          if ( $required )
  24          {
  25              if ( $empty )
  26              {
  27                  $this->field->submitted['on_error'] = 1;
  28                  return $this->field;
  29              }
  30          }
  31  
  32          $pattern     = $this->field->settings['options']['pattern'];
  33          if ( !$empty && !empty( $pattern ) ) $ereg_ok = ( isset( $this->field->settings['options']['ereg'] ) ) ? @preg_match( $pattern, $value ) : @preg_match( $pattern, strtolower( $value ) );
  34  
  35          if ( !$ereg_ok )
  36          {
  37              $this->field->submitted['on_error'] = 2;
  38              return $this->field;
  39          }
  40          return parent::submitted( $this->field );
  41      }
  42  }
  43  new MP_Form_field_type_ereg( __( 'Preg_match Input ', 'MailPress' ) );


Generated: Mon Mar 11 18:33:33 2019 Cross-referenced by PHPXref 0.7.1