public static function dateInput($config) { // month, day, year, required, and error message are optional $config['month'] = isset($config['month']) ? $config['month'] : ''; $config['day'] = isset($config['day']) ? $config['day'] : ''; $config['year'] = isset($config['year']) ? $config['year'] : ''; $config['required'] = isset($config['required']) ? $config['required'] : false; $config['errorMessage'] = isset($config['errorMessage']) ? $config['errorMessage'] : null; $string = '<div class="usa-date-of-birth">'; $string .= DateInput::buildInput('Month', $config['name'], '0?[1-9]|1[012]', 1, 12, $config['month'], $config['required'], $config['errorMessage']); $string .= DateInput::buildInput('Day', $config['name'], '0?[1-9]|1[0-9]|2[0-9]|3[01]', 1, 31, $config['day'], $config['required'], $config['errorMessage']); $string .= DateInput::buildInput('Year', $config['name'], '[0-9]{4}', 1900, 2000, $config['year'], $config['required'], $config['errorMessage']); $string .= '</div>'; return $string; }
/** * To allow the greatest flexibility in the definition of this element, * a keyed array is passed. * * Note: There is an issue when display errors, and a float-fix <code>div</code> has been added. * * Required keys * * **label:** The legend of the fieldset. * * **name:** The name of the field for POST data. Note: The name will be appended with 1, 2, 3, for month, day, and year, respectively. * * Optional keys * * **required:** true|false (default is false) - Whether the field is required or not. * * **hint:** An arbitrary non-block HTML string describing the purpose of the field. * * **errorMessage:** An arbitrary non-block HTML string describing the error found. * * **month:** The value of the month field. * * **day:** The value of the day field. * * **year:** The value of the year field. * * @param [type] $config [description] * @return [type] [description] */ public static function dateInput($config) { return DateInput::build($config); }