1 <?php
2 /**
3 * UIX Controls
4 *
5 * @package controls
6 * @author David Cramer
7 * @license GPL-2.0+
8 * @link
9 * @copyright 2016 David Cramer
10 */
11 namespace uix\ui\control;
12
13 /**
14 * Button field
15 *
16 * @since 1.0.0
17 */
18 class button extends template{
19
20 /**
21 * The type of object
22 *
23 * @since 1.0.0
24 * @access public
25 * @var string
26 */
27 public $type = 'button';
28
29 /**
30 * Gets the classes for the control input
31 *
32 * @since 1.0.0
33 * @access public
34 * @return array
35 */
36 public function classes() {
37
38 $classes = array(
39 'button'
40 );
41
42 if( !empty( $this->struct['attributes']['class'] ) )
43 $classes = (array) $this->struct['attributes']['class'];
44
45 return $classes;
46 }
47
48 /**
49 * Only if a button is given a value, then return it. this helps to determin which control was clicked.
50 * @since 1.0.0
51 * @access public
52 * @return mixed $data
53 */
54 public function get_data(){
55 $data = null;
56 if( !empty( $this->struct['value'] ) )
57 $data[ $this->slug ] = $this->struct['value'];
58
59 return $data;
60 }
61
62 /**
63 * Returns the main input field for rendering
64 *
65 * @since 1.0.0
66 * @see \uix\ui\uix
67 * @access public
68 * @return string Input field HTML striung
69 */
70 public function input(){
71
72 return '<button ' . $this->build_attributes() . '>' . esc_html( $this->struct['label'] ) . '</button>';
73 }
74
75
76
77
78 }