<?php

class ChimpFormHelper extends FormHelper {

	public function in($name, $options = [], $aliases = []) {

		// Get additional options
		if (key_exists('exceptions', $this->_View->viewVars) && !empty($this->_View->viewVars['exceptions'])) {
			foreach ($this->_View->viewVars['exceptions'] as $exception) {
				$aliases = array_merge([ $name ], $aliases);
				foreach ($aliases as $alias) {
					if ($exception['field'] === $alias) {
						$options['exception'] = ucfirst(str_replace('_', ' ', $exception['message']));
						break;
					}
				}
			}
		}

		return $this->input($name, $options);
	}

}