GFPDFHelperFieldsField_Html

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_Html.php  
  1. class Field_Html 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_HTML ) { 
  15. throw new Exception( '$field needs to be in instance of GF_Field_HTML' ); 
  16.  
  17. /** call our parent method */ 
  18. parent::__construct( $field, $entry, $gform, $misc ); 
  19.  
  20. /** 
  21. * Return the HTML form data 
  22. * @return array 
  23. * @since 4.0 
  24. */ 
  25. public function form_data() { 
  26.  
  27. $data = []; 
  28. $html = $this->value(); 
  29.  
  30. $data['html'][] = $html; 
  31. $data['html_id'][ $this->field->id ] = $html; 
  32.  
  33. return $data; 
  34.  
  35. /** 
  36. * Display the HTML version of this field 
  37. * @param string $value 
  38. * @param bool $label 
  39. * @return string 
  40. * @since 4.0 
  41. */ 
  42. public function html( $value = '', $label = true ) { 
  43. $html = $this->value(); /** allow the same HTML as per the post editor */ 
  44.  
  45. return parent::html( $html, false ); 
  46.  
  47. /** 
  48. * Get the standard GF value of this field 
  49. * @return string|array 
  50. * @since 4.0 
  51. */ 
  52. public function value() { 
  53. if ( $this->has_cache() ) { 
  54. return $this->cache(); 
  55.  
  56. $value = ( isset( $this->field->content ) ) ? wpautop( wp_kses_post( $this->field->content ) ) : ''; 
  57.  
  58. $this->cache( $value ); 
  59.  
  60. return $this->cache();