GFPDFHelperFieldsField_CreditCard

Controls the display and output of a Gravity Form field.

Defined (1)

The class is defined in the following location(s).

/src/helper/fields/Field_Creditcard.php  
  1. class Field_CreditCard extends Helper_Abstract_Fields { 
  2.  
  3. /** 
  4. * Check the appropriate variables are parsed in send to the parent construct 
  5. * @param object $field The GF_Field_* Object 
  6. * @param array $entry The Gravity Forms Entry 
  7. * @param \GFPDF\Helper\Helper_Abstract_Form $gform 
  8. * @param \GFPDF\Helper\Helper_Misc $misc 
  9. * @throws Exception 
  10. * @since 4.0 
  11. */ 
  12. public function __construct( $field, $entry, Helper_Abstract_Form $gform, Helper_Misc $misc ) { 
  13.  
  14. if ( ! is_object( $field ) || ! ( $field instanceof GF_Field_CreditCard ) ) { 
  15. throw new Exception( '$field needs to be in instance of GF_Field_CreditCard' ); 
  16.  
  17. /** call our parent method */ 
  18. parent::__construct( $field, $entry, $gform, $misc ); 
  19.  
  20. /** 
  21. * Display the HTML version of this field 
  22. * @param string $value 
  23. * @param bool $label 
  24. * @return string 
  25. * @since 4.0 
  26. */ 
  27. public function html( $value = '', $label = true ) { 
  28. $data = array_filter( $this->value() ); /** remove any empty fields from the array */ 
  29.  
  30. $value = implode( '<br>', $data ); 
  31.  
  32. return parent::html( $value ); 
  33.  
  34. /** 
  35. * Get the standard GF value of this field 
  36. * @return array 
  37. * @since 4.0 
  38. */ 
  39. public function value() { 
  40. if ( $this->has_cache() ) { 
  41. return $this->cache(); 
  42.  
  43. $value = $this->get_value(); 
  44.  
  45. $this->cache( [ 
  46. 'type' => esc_html( rgget( $this->field->id . '.4', $value ) ),  
  47. 'number' => esc_html( rgget( $this->field->id . '.1', $value ) ),  
  48. ] ); 
  49.  
  50. return $this->cache();