Set custom_attributes earlier

This commit is contained in:
Mike Jolley 2016-10-11 18:08:02 +01:00
parent c2958bcaa6
commit ed37f592bf
1 changed files with 14 additions and 13 deletions

View File

@ -1884,7 +1884,20 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
}
// Custom attribute handling
$custom_attributes = array();
$custom_attributes = array();
$args['custom_attributes'] = array_filter( (array) $args['custom_attributes'] );
if ( $args['maxlength'] ) {
$args['custom_attributes']['maxlength'] = absint( $args['maxlength'] );
}
if ( true === $args['autocomplete'] ) {
$args['custom_attributes']['autocomplete'] = 'true';
}
if ( true === $args['autofocus'] ) {
$args['custom_attributes']['autofocus'] = 'autofocus';
}
if ( ! empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) {
foreach ( $args['custom_attributes'] as $attribute => $attribute_value ) {
@ -1892,18 +1905,6 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
}
}
if ( $args['maxlength'] ) {
$custom_attributes['maxlength'] = absint( $args['maxlength'] );
}
if ( true === $args['autocomplete'] ) {
$custom_attributes['autocomplete'] = 'true';
}
if ( true === $args['autofocus'] ) {
$custom_attributes['autofocus'] = 'autofocus';
}
if ( ! empty( $args['validate'] ) ) {
foreach ( $args['validate'] as $validate ) {
$args['class'][] = 'validate-' . $validate;