Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gw-quantity-as-decimal.php: Fixed an issue with Calculation Product field not editable with decimal values. #720

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions gravity-forms/gw-quantity-as-decimal.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function init() {
add_filter( 'gform_field_input', array( $this, 'modify_quantity_input_tag' ), 10, 5 );
}

add_filter( 'gform_field_content', array( $this, 'fix_content' ), 10, 5 );
}

function allow_quantity_float( $result, $value, $form, $field ) {
Expand Down Expand Up @@ -87,6 +88,11 @@ function modify_quantity_input_tag( $markup, $field, $value, $lead_id, $form_id
return $markup;
}

function fix_content( $content, $field, $value, $lead_id, $form_id ) {
// ensure the quantity min attribute.
return preg_replace( '/\smin=["\']0["\']/', 'min="0" step="any"', $content );
Comment on lines +92 to +93
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on this. Can you make sure it's only targeting the desired fields and not all fields?

See the checks in modify_quantity_input_tag.

}

function get_field_input( $field, $value, $form ) {

remove_filter( 'gform_field_input', array( $this, 'modify_quantity_input_tag' ), 10, 5 );
Expand Down
Loading