NF_Abstracts_FieldOptIn

Class NF_Abstracts_FieldOptIn.

Defined (1)

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

/includes/Abstracts/FieldOptIn.php  
  1. abstract class NF_Abstracts_FieldOptIn extends NF_Abstracts_Input 
  2. protected $_name = 'optin'; 
  3.  
  4. protected $_section = 'misc'; 
  5.  
  6. protected $_parent_type = 'checkbox'; 
  7.  
  8. protected $_templates = 'optin'; 
  9.  
  10. protected $_settings = array( 'type', 'fieldset', 'checkbox_default_value' ); 
  11.  
  12. protected $_settings_exclude = array( 'default', 'required', 'placeholder', 'input_limit_set', 'disable_input' ); 
  13.  
  14. protected $_lists = array(); 
  15.  
  16. public function __construct() 
  17. parent::__construct(); 
  18.  
  19. /** 
  20. * Setup 'type' options for the opt-in field. 
  21. */ 
  22. $this->_settings[ 'type' ][ 'options' ] = array( 
  23. array( 
  24. 'label' => __( 'Single', 'ninja-forms' ),  
  25. 'value' => 'single',  
  26. ),  
  27. array( 
  28. 'label' => __( 'Multiple', 'ninja-forms' ),  
  29. 'value' => 'multiple',  
  30. ),  
  31. ); 
  32.  
  33. /** 
  34. * Add a refresh extra for the groups fieldset. 
  35. */ 
  36. $this->_settings[ 'fieldset' ][ 'label' ] = __( 'Lists', 'ninja-forms' ) . ' <a href="#"><small>' . __( 'refresh', 'ninja-forms' ) . '</small></a>'; 
  37. $this->_settings[ 'fieldset' ][ 'deps' ] = array( 'type' => 'multiple' ); 
  38.  
  39. /** 
  40. * Hide the 'type' and 'fieldset' ('groups') settings until they are ready for use. 
  41. */ 
  42. $this->_settings[ 'type' ][ 'group' ] = ''; 
  43. $this->_settings[ 'fieldset' ][ 'group' ] = ''; 
  44.  
  45. protected function addList( $name, $label ) 
  46. $this->_settings[ 'fieldset' ][ 'settings' ][] = array( 
  47. 'name' => $name,  
  48. 'type' => 'toggle',  
  49. 'label' => $label,  
  50. 'width' => 'full',  
  51. 'value' => '' 
  52. ); 
  53.  
  54. protected function addLists( array $lists = array() ) 
  55. if( empty( $lists ) ) return; 
  56.  
  57. foreach( $lists as $name => $label ) { 
  58. $this->addList( $name, $label ); 
  59.  
  60. public function get_parent_type() { 
  61. return $this->_parent_type; 
  62.