GFPDFHelperFieldsField_Post_Custom_Field

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_Post_Custom_Field.php  
  1. class Field_Post_Custom_Field 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. /** call our parent method */ 
  15. parent::__construct( $field, $entry, $gform, $misc ); 
  16.  
  17. /** 
  18. * Custom Field can be any of the following field types: 
  19. * single line text, paragraph, dropdown, select, number, checkbox, radio, hidden,  
  20. * date, time, phone, website, email, file upload or list 
  21. */ 
  22. $class = $this->misc->get_field_class( $field->inputType ); 
  23.  
  24. try { 
  25. /** check load our class */ 
  26. if ( class_exists( $class ) ) { 
  27.  
  28. /** See https://gravitypdf.com/documentation/v4/gfpdf_field_class/ for more details about these filters */ 
  29. $this->fieldObject = apply_filters( 'gfpdf_field_class', new $class( $field, $entry, $gform, $misc ), $field, $entry, $this->form ); 
  30. $this->fieldObject = apply_filters( 'gfpdf_field_class_' . $field->inputType, $this->fieldObject, $field, $entry, $this->form ); 
  31. } else { 
  32. throw new Exception( 'Class not found' ); 
  33. } catch ( Exception $e ) { 
  34. /** Exception thrown. Load generic field loader */ 
  35. $this->fieldObject = apply_filters( 'gfpdf_field_default_class', new Field_Default( $field, $entry, $gform, $misc ), $field, $entry, $this->form ); 
  36.  
  37. /** force the fieldObject value cache */ 
  38. $this->value(); 
  39.  
  40. /** 
  41. * Used to check if the current field has a value 
  42. * @since 4.0 
  43. */ 
  44. public function is_empty() { 
  45. return $this->fieldObject->is_empty(); 
  46.  
  47. /** 
  48. * Display the HTML version of this field 
  49. * @param string $value 
  50. * @param bool $label 
  51. * @return string 
  52. * @since 4.0 
  53. */ 
  54. public function html( $value = '', $label = true ) { 
  55. return $this->fieldObject->html(); 
  56.  
  57. /** 
  58. * Return the correct form data information for the selected fields 
  59. * @return array 
  60. * @since 4.0 
  61. */ 
  62. public function form_data() { 
  63. if ( method_exists( $this->fieldObject, 'form_data' ) ) { 
  64. return $this->fieldObject->form_data(); 
  65.  
  66. return parent::form_data(); 
  67.  
  68. /** 
  69. * Get the standard GF value of this field 
  70. * @return string|array 
  71. * @since 4.0 
  72. */ 
  73. public function value() { 
  74. if ( $this->fieldObject->has_cache() ) { 
  75. return $this->fieldObject->cache(); 
  76.  
  77. $value = $this->fieldObject->value(); 
  78.  
  79. $this->fieldObject->cache( $value ); 
  80.  
  81. return $this->fieldObject->cache();