Add Number Field Element
-
To whom it may concern,
I am currently busy developing an addon for WP Forms and I want to be able to add a number field to the Field Options -> General Settings within the WP Forms Builder. Sadly the field_element() function doesn’t allow the number field type.
I am not sure if here is the correct place to enquire about potentially getting an update for this. I can add the needed code to the WP Forms plugin myself to add support for the number field type, but should WP Forms push an update in the future, it will overwrite my change.
The Code that should be added to the class-base.php is as follows:
// Number input.
case 'number':
$type = ! empty( $args['type'] ) ? esc_attr( $args['type'] ) : 'number';
$placeholder = ! empty( $args['placeholder'] ) ? esc_attr( $args['placeholder'] ) : '';
$before = ! empty( $args['before'] ) ? '<span class="before-input">' . esc_html( $args['before'] ) . '</span>' : '';
$after = ! empty( $args['after'] ) ? '<span class="after-input sub-label">' . esc_html( $args['after'] ) . '</span>' : '';
if ( ! empty( $before ) ) {
$class .= ' has-before';
}
if ( ! empty( $after ) ) {
$class .= ' has-after';
}
$output = sprintf( '%s<input type="%s" class="%s" id="wpforms-field-option-%d-%s" name="fields[%d][%s]" value="%s" placeholder="%s" %s>%s', $before, $type, $class, $id, $slug, $id, $slug, esc_attr( $args['value'] ), $placeholder, $attrs, $after );
break;
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Add Number Field Element’ is closed to new replies.