/includes/skip/elements/forms/hidden.php

  1. <?php 
  2. /** 
  3. * Skip Hidden Field class 
  4. * @package Skip\Forms 
  5. * @since 1.0 
  6. * @ignore 
  7. */ 
  8.  
  9. namespace skip\v1_0_0; 
  10.  
  11. class Hidden extends Form_Element{ 
  12. /** 
  13. * Constructor 
  14. * @since 1.0 
  15. * @param string $name The name of field. 
  16. * @param array/string $args List of Arguments. 
  17. */ 
  18. function __construct( $name, $args = array() ) { 
  19. global $post, $skip_form_option_group; 
  20.  
  21. $args = wp_parse_args( $args ); 
  22. extract( $args , EXTR_SKIP ); 
  23.  
  24. $args[ 'close_tag' ] = FALSE; // No Close tag for Input type Text 
  25. parent::__construct( 'input', $name, $args ); 
  26.  
  27. $this->add_param( 'type', 'hidden' ); // This is a text field! 
  28. /** 
  29. * Hidden Field getter Function 
  30. * @see skip_hidden() 
  31. * @ignore 
  32. */ 
  33. function get_hidden( $name, $args = array(), $return = 'html' ) { 
  34. $hidden = new Hidden( $name, $args ); 
  35. return element_return( $hidden, $return ); 
  36. /** 
  37. * <pre>skip_hidden( $name, $args )</pre> 
  38. *  
  39. * Adding a Hidden field. 
  40. *  
  41. * <b>Default Usage</b> 
  42. * <code> 
  43. * skip_hidden( 'myhiddenfield' ); 
  44. * </code> 
  45. * This will create an automated saved hidden field. 
  46. *  
  47. * <b>Parameters</b> 
  48. *  
  49. * <code> 
  50. * $name // (string) (required) The name of the field. 
  51. * $args // (array) (optional) Values for further settings. 
  52. * </code> 
  53. *  
  54. * <b>$args Settings</b> 
  55. *  
  56. * <ul> 
  57. * <li>id (string) ID if the HTML Element.</li>  
  58. * <li>label (string) Label for Element.</li>  
  59. * <li>default (string) Default Value if no Value is set before.</li> 
  60. * <li>classes (string) Name of CSS Classes which will be inserted into HTML seperated by empty space.</li> 
  61. * <li>before_element (string) Content before the element.</li> 
  62. * <li>after_element (string) Content after the element.</li> 
  63. * <li>save (boolean) TRUE if value of field have to be saved in Database, FALSE if not (default TRUE).</li> 
  64. * </ul> 
  65. *  
  66. * <b>Example</b> 
  67. *  
  68. * Creating a hidden field in an automatic saved form. 
  69. * <code> 
  70. * skip_form_start( 'myformname' ); 
  71. *  
  72. * $args = array( 
  73. * 'id' = 'myelementid',  
  74. * 'label' => 'Content' 
  75. * ); 
  76. * skip_editor( 'myhiddenfield', $args ); 
  77. *  
  78. * skip_form_end(); 
  79. * </code> 
  80. *  
  81. * Getting back the saved data. 
  82. * <code> 
  83. * $value = skip_value( 'myformname', 'myhiddenfield' ); 
  84. * </code> 
  85. * @package Skip\Forms 
  86. * @since 1.0 
  87. * @param string $name Name of field. 
  88. * @param array/string $args List of Arguments. 
  89. */ 
  90. function hidden( $name, $args = array() ) { 
  91. echo get_hidden( $name, $args, 'echo' ); 
.