/includes/skip/elements/forms/text.php

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