PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.3.1
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.3.1
2.7.7 2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 2.6.1 2.7.0 All 28 releases
insert-php / libs / factory / forms / controls / textbox.php

textbox.php in Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts 2.3.1, at libs/factory/forms/controls/textbox.php

84 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Textbox Control
5 *
6 * Main options:
7 * name => a name of the control
8 * value => a value to show in the control
9 * default => a default value of the control if the "value" option is not specified
10 * maxLength => set the max length of text in the input control
11 * placeholder => a placeholder text for the control when the control value is empty
12 *
13 * Использование datepicker в текстовом поле (необ�
14 одимо подключить bootstrap.datepicker)
15 * 'htmlAttrs' => array(
16 * 'data-provide' => 'datepicker-inline',
17 * 'data-date-language' => 'ru',
18 * 'data-date-autoclose' => 'true'
19 * )
20 *
21 * @author Alex Kovalev <alex.kovalevv@gmail.com>
22 * @copyright (c) 2018, Webcraftic Ltd
23 *
24 * @package factory-forms
25 * @since 1.0.0
26 */
27
28 // Exit if accessed directly
29 if( !defined('ABSPATH') ) {
30 exit;
31 }
32
33 if( !class_exists('Wbcr_FactoryForms420_TextboxControl') ) {
34
35 class Wbcr_FactoryForms420_TextboxControl extends Wbcr_FactoryForms420_Control {
36
37 public $type = 'textbox';
38
39 /**
40 * Preparing html attributes before rendering html of the control.
41 *
42 * @since 1.0.0
43 * @return void
44 */
45 protected function beforeHtml()
46 {
47 $value = esc_attr($this->getValue());
48 $name_on_form = $this->getNameOnForm();
49
50 if( $this->getOption('maxLength', false) ) {
51 $this->addHtmlAttr('maxlength', intval($this->getOption('maxLength')));
52 }
53
54 if( $this->getOption('placeholder', false) ) {
55 $this->addHtmlAttr('placeholder', $this->getOption('placeholder'));
56 }
57
58 $this->addCssClass('form-control');
59 $this->addHtmlAttr('type', 'text');
60 $this->addHtmlAttr('id', $name_on_form);
61 $this->addHtmlAttr('name', $name_on_form);
62 $this->addHtmlAttr('value', $value);
63 }
64
65 /**
66 * Shows the html markup of the control.
67 *
68 * @since 1.0.0
69 * @return void
70 */
71 public function html()
72 {
73 $units = $this->getOption('units', false);
74 ?>
75 <?php if( $units ) { ?><div class="input-group"><?php } ?>
76 <input <?php $this->attrs() ?>/>
77 <?php if( $units ) { ?>
78 <span class="input-group-addon"><?php echo $units; ?></span>
79 <?php } ?>
80 <?php if( $units ) { ?></div><?php } ?>
81 <?php
82 }
83 }
84 }