Code Duplication    Length = 33-39 lines in 2 locations

classes/fields/number.php 1 location

@@ 224-256 (lines=33) @@
221
     *
222
     * @since 2.0
223
     */
224
    public function input ( $name, $value = null, $options = null, $pod = null, $id = null ) {
225
        $options = (array) $options;
226
        $form_field_type = PodsForm::$field_type;
227
228
        if ( is_array( $value ) )
229
            $value = implode( '', $value );
230
231
        if ( 'slider' == pods_var( self::$type . '_format_type', $options, 'number' ) )
232
            $field_type = 'slider';
233
        else
234
            $field_type = 'number';
235
236
        if ( isset( $options[ 'name' ] ) && false === PodsForm::permission( self::$type, $options[ 'name' ], $options, null, $pod, $id ) ) {
237
            if ( pods_var( 'read_only', $options, false ) )  {
238
                $options[ 'readonly' ] = true;
239
240
                $field_type = 'text';
241
242
                $value = $this->format( $value, $name, $options, $pod, $id );
243
            }
244
            else
245
                return;
246
        }
247
        elseif ( !pods_has_permissions( $options ) && pods_var( 'read_only', $options, false ) ) {
248
            $options[ 'readonly' ] = true;
249
250
            $field_type = 'text';
251
252
            $value = $this->format( $value, $name, $options, $pod, $id );
253
        }
254
255
        pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) );
256
    }
257
258
    /**
259
     * Build regex necessary for JS validation

classes/fields/currency.php 1 location

@@ 343-381 (lines=39) @@
340
	 *
341
	 * @since 2.0
342
	 */
343
	public function input( $name, $value = null, $options = null, $pod = null, $id = null ) {
344
345
		$options = (array) $options;
346
		$form_field_type = PodsForm::$field_type;
347
348
		if ( is_array( $value ) ) {
349
			$value = implode( '', $value );
350
		}
351
352
		if ( 'slider' == pods_v( self::$type . '_format_type', $options, 'number' ) ) {
353
			$field_type = 'slider';
354
		}
355
		else {
356
			$field_type = 'currency';
357
		}
358
359
		if ( isset( $options[ 'name' ] ) && false === PodsForm::permission( self::$type, $options[ 'name' ], $options, null, $pod, $id ) ) {
360
			if ( pods_v( 'read_only', $options, false ) ) {
361
				$options[ 'readonly' ] = true;
362
363
				$field_type = 'text';
364
365
				$value = $this->format( $value, $name, $options, $pod, $id );
366
			}
367
			else {
368
				return;
369
			}
370
		}
371
		elseif ( !pods_has_permissions( $options ) && pods_v( 'read_only', $options, false ) ) {
372
			$options[ 'readonly' ] = true;
373
374
			$field_type = 'text';
375
376
			$value = $this->format( $value, $name, $options, $pod, $id );
377
		}
378
379
		pods_view( PODS_DIR . 'ui/fields/' . $field_type . '.php', compact( array_keys( get_defined_vars() ) ) );
380
381
	}
382
383
	/**
384
	 * Build regex necessary for JS validation