Code Duplication    Length = 33-39 lines in 2 locations

classes/fields/currency.php 1 location

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

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