/includes/skip/elements/forms/textarea.php

  1. <?php 
  2. /** 
  3. * Skip Textarea class 
  4. * @package Skip 
  5. * @since 1.0 
  6. * @ignore 
  7. */ 
  8.  
  9. namespace skip\v1_0_0; 
  10.  
  11. class Textarea 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, $label = FALSE, $args = array() ) { 
  20. $defaults = array( 
  21. 'rows' => '',  
  22. 'cols' => '',  
  23. 'description' => '',  
  24. 'default' => '',  
  25. 'disabled' => FALSE 
  26. ); 
  27.  
  28. $args = wp_parse_args( $args, $defaults ); 
  29. $args[ 'label' ] = $label; 
  30. $args[ 'close_tag' ] = TRUE; // No Close tag for Input type Text 
  31.  
  32. parent::__construct( 'textarea', $name, $args ); 
  33.  
  34. if( '' != $args[ 'rows' ] ) 
  35. $this->add_param( 'rows', $args[ 'rows' ] ); 
  36.  
  37. if( '' != $args[ 'cols' ] ) 
  38. $this->add_param( 'cols', $args[ 'cols' ] ); 
  39.  
  40. if( '' != $this->value ) 
  41. $this->add_element( $this->value ); 
  42.  
  43. $this->del_param( 'value' ); // Not needed here 
  44. /** 
  45. * Textarea getter Function 
  46. * @see skip_textarea() 
  47. * @ignore 
  48. */ 
  49. function get_textarea( $name, $label = FALSE, $args = array() ) { 
  50. $textarea = new Textarea( $name, $label, $args ); 
  51. return $textarea->render(); 
  52. }  
  53. /** 
  54. * <pre>skip_textarea( $name, $args );</pre> 
  55. *  
  56. * Adding a Textarea. 
  57. *  
  58. * <b>Default Usage</b> 
  59. * <code> 
  60. * skip_textarea( 'mytext' ); 
  61. * </code> 
  62. * This will create an automated saved textarea field. 
  63. *  
  64. * <b>Parameters</b> 
  65. *  
  66. * <code> 
  67. * $name // (string) (required) The name of the field. 
  68. * $args // (array/string) (optional) Values for further settings. 
  69. * </code> 
  70. *  
  71. * <b>$args Settings</b> 
  72. *  
  73. * <ul> 
  74. * <li>id (string) ID if the HTML Element.</li>  
  75. * <li>label (string) Label for Element.</li>  
  76. * <li>default (string) Default Value if no Value is set before.</li> 
  77. * <li>cols (int) Number of columns of the Textarea.</li> 
  78. * <li>rows (int) Number of rows of the Textarea.</li> 
  79. * <li>classes (string) Name of CSS Classes which will be inserted into HTML seperated by empty space.</li> 
  80. * <li>before_element (string) Content before the element.</li> 
  81. * <li>after_element (string) Content after the element.</li> 
  82. * </ul> 
  83. *  
  84. * <b>Example</b> 
  85. *  
  86. * Creating a labeled Textarea with 10 rows in an automatic saved form. 
  87. * <code> 
  88. * skip_form_start( 'myformname' ); 
  89. *  
  90. * skip_textarea( 'mytext', 'label=Name&rows=10' ); 
  91. *  
  92. * skip_form_end(); 
  93. * </code> 
  94. *  
  95. * Getting back the saved data. 
  96. * <code> 
  97. * $value = skip_value( 'mytext', 'name' ); 
  98. * </code> 
.