<?php
namespace Website\Widgets\ContactForm\InputFilter; use Moto; class Message extends Moto\InputFilter\AbstractInputFilter { public function init() { $this->add(array( 'name' => 'email', 'required' => false, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'validators' => array( array( 'name' => 'EmailAddress', 'options' => array( 'useMxCheck' => false, 'useDeepMxCheck' => false, 'useDomainCheck' => false, ), ), ), )); $this->add(array( 'name' => 'name', 'required' => false, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'validators' => array( array( 'name' => 'StringLength', 'options' => array( 'encoding' => 'UTF-8', 'max' => 200, ), ), ), )); $this->add(array( 'name' => 'phone', 'required' => false, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'validators' => array( array( 'name' => 'StringLength', 'options' => array( 'encoding' => 'UTF-8', 'max' => 200, ), ), ), )); $this->add(array( 'name' => 'address', 'required' => false, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'validators' => array( array( 'name' => 'StringLength', 'options' => array( 'encoding' => 'UTF-8', 'max' => 200, ), ), ), )); $this->add(array( 'name' => 'subject', 'required' => false, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'validators' => array( array( 'name' => 'StringLength', 'options' => array( 'encoding' => 'UTF-8', 'max' => 200, ), ), ), )); $this->add(array( 'name' => 'message', 'required' => false, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'validators' => array( array( 'name' => 'StringLength', 'options' => array( 'encoding' => 'UTF-8', 'max' => 2048, ), ), ), )); $this->add(array( 'name' => 'checkbox', 'required' => false, 'validators' => array( array( 'name' => 'InArray', 'options' => array( 'haystack' => array('Yes', 'No') ) ), ), )); $this->add(array( 'name' => '_attachments', 'required' => false, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), )); } public function getValues($keys = null, $ignoreDefault = false) { $_values = $values = parent::getValues($keys, $ignoreDefault); foreach($values as $key => $value) { if (empty($value)) { unset($_values[$key]); } } return $_values; } } 