PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/fields/FrmFieldNumber.php +9 -8 6.26 → trunk View file →
@@ -58,8 +58,11 @@
58 58 protected function add_extra_html_atts( $args, &$input_html ) {
59 59 $this->add_min_max( $args, $input_html );
60 60 }
61 61
62 + /**
63 + * @param array $args
64 + */
62 65 public function validate( $args ) {
63 66 $errors = array();
64 67
65 68 $this->remove_commas_from_number( $args );
@@ -162,12 +165,14 @@
162 165 *
163 166 * @return void
164 167 */
165 168 private function remove_commas_from_number( &$args ) {
166 - if ( strpos( $args['value'], ',' ) ) {
167 - $args['value'] = str_replace( ',', '', $args['value'] );
168 - FrmEntriesHelper::set_posted_value( $this->field, $args['value'], $args );
169 + if ( ! str_contains( $args['value'], ',' ) ) {
170 + return;
169 171 }
172 +
173 + $args['value'] = str_replace( ',', '', $args['value'] );
174 + FrmEntriesHelper::set_posted_value( $this->field, $args['value'], $args );
170 175 }
171 176
172 177 /**
173 178 * Force the value to be numeric before it's saved in the DB
@@ -176,13 +181,9 @@
176 181 *
177 182 * @return float
178 183 */
179 184 public function set_value_before_save( $value ) {
180 - if ( ! is_numeric( $value ) ) {
181 - $value = (float) $value;
182 - }
183 -
184 - return $value;
185 + return is_numeric( $value ) ? $value : (float) $value;
185 186 }
186 187
187 188 /**
188 189 * @since 4.0.04