Caldera_Forms_Field_HTML

Base class for creating field element HTML.

Defined (1)

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

/classes/field/html.php  
  1. abstract class Caldera_Forms_Field_HTML { 
  2.  
  3.  
  4. /** 
  5. * Create HTML form the field element (not the wrapper) 
  6. * This must be ovveriden in subclass 
  7. * @since 1.5.0 
  8. * @param array $field Field config 
  9. * @param array $field_structure Prepared field structure 
  10. * @param array $form Form config 
  11. * @return string 
  12. */ 
  13. public static function html( array $field, array $field_structure, array $form ) { 
  14. return ''; 
  15.  
  16. /** 
  17. * Create the aria attributes string 
  18. * @since 1.5.0 
  19. * @param array $field_structure Prepared field structure 
  20. * @return string 
  21. */ 
  22. protected static function aria_string( $field_structure ) { 
  23. if( is_string( $field_structure[ 'aria' ] ) ) { 
  24. return $field_structure[ 'aria' ]; 
  25. }elseif ( ! empty( $field_structure[ 'aria' ] ) ) { 
  26. $attrs = caldera_forms_escape_field_attributes_array( $field_structure[ 'aria' ], 'aria-' ); 
  27. return caldera_forms_implode_field_attributes( $attrs ); 
  28.  
  29. return ''; 
  30.  
  31.  
  32. /** 
  33. * Get placeholder string for field 
  34. * @since 1.5.0 
  35. * @param array $field Field config 
  36. * @param string $placeholder Optional. Ovveride for field's configured placeholder 
  37. * @return string 
  38. */ 
  39. protected static function place_holder_string( array $field, $placeholder = '' ) { 
  40. if( empty( $placeholder ) && ( ! empty( $field[ 'config' ][ 'placeholder' ] ) || ( isset( $field[ 'config' ][ 'placeholder' ] ) && is_numeric( $field[ 'config' ][ 'placeholder' ] ) ) ) ) { 
  41. $placeholder = $field[ 'config' ][ 'placeholder' ]; 
  42.  
  43. if ( ! empty( $placeholder ) || is_numeric( $placeholder ) ) { 
  44. return 'placeholder="' . esc_attr( Caldera_Forms::do_magic_tags( $placeholder ) ) . '"'; 
  45.  
  46. return ''; 
  47.  
  48.  
  49. /** 
  50. * Get field default value 
  51. * @since 1.5.0 
  52. * @param array $field 
  53. * @param array $form 
  54. * @return mixed 
  55. */ 
  56. public static function find_default( array $field, array $form ) { 
  57. if ( isset( $field[ 'slug' ] ) && isset( $_GET[ $field[ 'slug' ] ] ) ) { 
  58. $default = Caldera_Forms_Sanitize::sanitize( $_GET[ $field[ 'slug' ] ] ); 
  59. }elseif ( isset( $field[ 'config' ][ 'default' ] ) ) { 
  60. $default = Caldera_Forms::do_magic_tags( $field[ 'config' ][ 'default' ], null, $form ); 
  61. }else{ 
  62. $default = ''; 
  63.  
  64. return $default; 
  65.  
  66.  
  67.