PluginProbe
Disable Comments & Delete All Comments / 1.3.0
Disable Comments & Delete All Comments v1.3.0
1.3.3 1.3.2 trunk 1.0.0 1.0.4 1.0.5 1.0.8 1.0.9 1.1.1 1.1.3 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.3.0 1.3.1
comments-plus / libs / factory / forms / controls / textbox.php

textbox.php in Disable Comments & Delete All Comments 1.3.0, at libs/factory/forms/controls/textbox.php

84 lines 2.2 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_FactoryForms480_TextboxControl') ) {
34
35 class Wbcr_FactoryForms480_TextboxControl extends Wbcr_FactoryForms480_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 esc_html($units); ?></span>
79 <?php } ?>
80 <?php if( $units ) { ?></div><?php } ?>
81 <?php
82 }
83 }
84 }