/** * HomeController::filter() * The filters group for form validation * @param array $aryData * @param string $strField * @param string $strSubField * @return array( $success, $aryMsg, $aryResultData ) **/ public function filter($aryData, $strField, $strSubField = null) { $strField = array_pop(explode('::', $strField)); $aryControlFilterList = array('index' => array('firstname' => array(array('call_func' => array('DataValidateExt', 'clear_html_string')), array('filter' => FILTER_SANITIZE_STRING, 'options' => FILTER_FLAG_ENCODE_HIGH | FILTER_FLAG_ENCODE_LOW), array('filter' => FILTER_VALIDATE_REGEXP, 'options' => array('regexp' => '/^(\\w+){3,30}$/'), 'msg' => 'Name is not valid, 3 more charactors required'), 'msg' => 'Name is not valid, a-z, 0-9, _, 5 ~ 30 charactors only'), 'lastname' => array(array('call_func' => array('DataValidateExt', 'clear_html_string')), array('filter' => FILTER_SANITIZE_STRING, 'options' => FILTER_FLAG_ENCODE_HIGH | FILTER_FLAG_ENCODE_LOW), array('filter' => FILTER_VALIDATE_REGEXP, 'options' => array('regexp' => '/^(\\w+){2,30}$/'), 'msg' => 'Name is not valid, 2 more charactors required'), 'msg' => 'Name is not valid, a-z, 0-9, _, 2 ~ 30 charactors only'), 'dob' => array(array('options' => 'date::{-100 years,,today}'), 'msg' => 'Date of Birth is not valid'), 'email' => array(array('filter' => FILTER_SANITIZE_EMAIL), array('filter' => FILTER_VALIDATE_EMAIL), 'msg' => 'Email is not valid'), 'comments' => array(array('call_func' => array('DataValidateExt', 'clear_html_string')), array('filter' => FILTER_SANITIZE_STRING, 'options' => FILTER_FLAG_ENCODE_HIGH | FILTER_FLAG_ENCODE_LOW), array('options' => 'text::{1,,8000}'), 'msg' => 'Comment is not valid, 1 ~ 8000 charactors only'))); if ($strSubField) { if (array_key_exists($strSubField, $aryControlFilterList[$strField])) { return DataValidateExt::validate($aryData, array($strSubField => $aryControlFilterList[$strField][$strSubField])); } else { return array(false, array(), array()); } } return DataValidateExt::validate($aryData, $aryControlFilterList[$strField]); }
<div class="form-group <?php echo $this->getErrorMsg('email') ? 'has-error has-feedback' : ($this->getRequest('email') ? 'has-success has-feedback' : ''); ?> "> <label for="inputEmail">EMAIL ADDRESS</label> <input value="<?php echo DataValidateExt::clear_html_string($this->getRequest('email')); ?> " type="email" id="inputEmail" name="email" class="form-control" placeholder="EMAIL ADDRESS" title="<?php echo $this->getErrorMsg('email') ? DataValidateExt::clear_html_string($this->getErrorMsg('email')) : 'EMAIL ADDRESS'; ?> " required> <span class="glyphicon <?php echo $this->getErrorMsg('email') ? 'glyphicon-remove' : ($this->getRequest('email') ? 'glyphicon-ok' : ''); ?> form-control-feedback" aria-hidden="true"></span> </div>
<div class="form-group <?php echo $this->getErrorMsg('lastname') ? 'has-error has-feedback' : ($this->getRequest('lastname') ? 'has-success has-feedback' : ''); ?> "> <label for="inputLastname">LASTNAME</label> <input value="<?php echo DataValidateExt::clear_html_string($this->getRequest('lastname')); ?> " type="text" id="inputLastname" name="lastname" class="form-control" placeholder="LASTNAME" title="<?php echo $this->getErrorMsg('lastname') ? DataValidateExt::clear_html_string($this->getErrorMsg('lastname')) : 'LASTNAME'; ?> " required> <span class="glyphicon <?php echo $this->getErrorMsg('lastname') ? 'glyphicon-remove' : ($this->getRequest('lastname') ? 'glyphicon-ok' : ''); ?> form-control-feedback" aria-hidden="true"></span> </div>
<div class="form-group <?php echo $this->getErrorMsg('dob') ? 'has-error has-feedback' : ($this->getRequest('dob') ? 'has-success has-feedback' : ''); ?> " title="<?php echo $this->getErrorMsg('dob') ? DataValidateExt::clear_html_string($this->getErrorMsg('dob')) : 'DATE OF BIRTH'; ?> "> <label for="inputDay">DATE OF BIRTH</label> <div class="block-datefield"> <div class="datefield"> <input value="<?php echo DataValidateExt::clear_html_string($this->getRequest('dob-dd')); ?> " id="inputDay" name="dob-dd" type="tel" maxlength="2" placeholder="DD" required /> / <input value="<?php echo DataValidateExt::clear_html_string($this->getRequest('dob-mm')); ?> " id="inputMonth" name="dob-mm" type="tel" maxlength="2" placeholder="MM" required /> / <input value="<?php echo DataValidateExt::clear_html_string($this->getRequest('dob-yyyy')); ?> " id="inputYear" name="dob-yyyy" type="tel" maxlength="4" placeholder="YYYY" required /> <span class="glyphicon <?php echo $this->getErrorMsg('dob') ? 'glyphicon-remove' : ($this->getRequest('dob') ? 'glyphicon-ok' : ''); ?> form-control-feedback" aria-hidden="true"></span> </div> </div> </div>
<div class="form-group <?php echo $this->getErrorMsg('comments') ? 'has-error' : ($this->getRequest('comments') ? 'has-success has-feedback' : ''); ?> "> <label for="inputComments">COMMENT</label> <textarea id="inputComments" name="comments" class="form-control" rows="5" placeholder="COMMENT" title="<?php echo $this->getErrorMsg('comments') ? DataValidateExt::clear_html_string($this->getErrorMsg('comments')) : ''; ?> "><?php echo DataValidateExt::clear_html_string($this->getRequest('comments')); ?> </textarea> <span class="glyphicon <?php echo $this->getErrorMsg('comments') ? 'glyphicon-remove' : ($this->getRequest('comments') ? 'glyphicon-ok' : ''); ?> form-control-feedback" aria-hidden="true"></span> </div>
<table border="1" style="width:100%" cellspacing="5" cellpadding="5"> <?php foreach ($this->aryRequest as $strField => $strData) { ?> <tr> <th><?php echo DataValidateExt::clear_html_string($strField); ?> </th> <td><?php echo DataValidateExt::clear_html_string($this->getRequest($strField)); ?> </td> </tr> <?php } ?> </table>