build_field_types

The Caldera Forms build field types function.

Description

build_field_types( (constant) $default = null ); 

Parameters (1)

0. $default — Optional. (constant) => null
The default.

Usage

  1. if ( !function_exists( 'build_field_types' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'caldera-forms/ui/edit.php'; 
  3.  
  4. // The default. 
  5. $default = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = build_field_types($default); 
  9.  

Defined (1)

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

/ui/edit.php  
  1. function build_field_types($default = null) { 
  2. global $field_type_list; 
  3.  
  4.  
  5. $out = ''; 
  6. if(null === $default) { 
  7. $out .= '<option></option>'; 
  8.  
  9. foreach($field_type_list as $category=>$fields) { 
  10.  
  11. $out .= "<optgroup label=\" ". $category . "\">\r\n"; 
  12. foreach ($fields as $field => $config) { 
  13.  
  14. $sel = ""; 
  15. if( $default === null ) { 
  16. $sel = "{{#is type value=\"" . $field . "\"}}selected=\"selected\"{{/is}}"; 
  17. if($default == $field) { 
  18. $sel = 'selected="selected"'; 
  19.  
  20. $out .= "<option value=\"". $field . "\" ". $sel .">" . $config['field'] . "</option>\r\n"; 
  21. $out .= "</optgroup>"; 
  22.  
  23. return $out; 
  24.