Permalink
Browse files

Copy field validation

  • Loading branch information...
1 parent 48b29ce commit a6b8acc8211cd1d21f7a7d164869dd73fe104813 @Horttcore committed Nov 7, 2011
Showing with 18 additions and 1 deletion.
  1. +18 −1 class.formz.php
View
19 class.formz.php
@@ -52,6 +52,16 @@ class formz {
/**
+ * Error message if to copy field is checked but copy_to isn't filled out
+ *
+ * @access public
+ * @var string Form field name
+ **/
+ public $copy_message;
+
+
+
+ /**
* Which field should handle the copy email address
*
* @access public
@@ -1121,12 +1131,19 @@ protected function checkfield( $e, $return_error_message = FALSE )
**/
protected function checkform()
{
+ // Get submitted form data
if ( 'post' == $this->method && isset($_POST['formz-' . $this->id ]) ) :
$this->data = $_POST;
elseif ( 'get' == $this->method && isset($_GET['formz-' . $this->id ]) ) :
$this->data = $_GET;
endif;
-
+
+ // Copy to validation
+ if ( $this->copy && $this->copy_to && isset($this->data['copy']) ) :
+ $this->required('name=' . $this->copy_to . '&error_message=' . $this->copy_message);
+ endif;
+
+ // Check the form
if ( $this->form ) :
foreach ( $this->form as $element ) :

0 comments on commit a6b8acc

Please sign in to comment.