<div class="contentpanel">
        <p class="mb20"><a href="http://datatables.net/" target="_blank">DataTables</a> is a plug-in for the jQuery Javascript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, and will add advanced interaction controls to any HTML table.</p>

        <div class="panel panel-primary-head">
            <div class="panel-heading">
                <h4 class="panel-title">Basic Configuration</h4>
                <p>Searching, ordering, paging etc goodness will be immediately added to the table, as shown in this example.</p>
            </div><!-- panel-heading -->
            <br>

        <form action="<?php 
echo $this->createUrl("/trucks/CreateAndSendAccess");
?>
" method="post">
         <?php 
echo FormHTML::select_simple($accounts, "accounts", "accounts", "Новый аккаунт", "user");
echo "<br><br>";
foreach ($plates as $plate) {
    echo "Номера: <input type='text' name='plates[]' size='20' value='" . $plate . "'><br>";
}
?>
         <br><br>
         Номер телефона: <input type="text" name="phone" class="mask"><br><br>
        <input type="submit" value="ПШЁЛ">
        </form>
        </div><!-- panel -->
        <br />



    </div><!-- contentpanel -->
Exemplo n.º 2
0
<?php

require_once DISK_ROOT . '/framework/controls/form/form_html.php';
$css = '<link href="' . href('/framework/controls/form/form.css') . '" rel="stylesheet" media="screen" type="text/css" />';
$this->getHead()->appendContent($css);
$form = new FormHTML($this->control_options);
if ($form->checkRequired()) {
    $form->addMethod();
    $form->process();
    echo $form->getForm();
}
 /**
  * Render an element
  * @param object $element
  * @return string
  */
 protected function element($element)
 {
     // set id
     if (!isset($element->attributes['id'])) {
         $element->id = $this->id();
         $attributes = $element->attributes;
         $attributes['id'] = $element->id;
         $element->attributes = $attributes;
     } else {
         $element->id = $element->attributes['id'];
     }
     // set class
     if (!isset($element->attributes['class'])) {
         // set bootstap class
         $attributes['class'] = '';
     }
     // set label
     if (!$element->label) {
         if ($element->text) {
             $element->label = $this->_text->get($element->text);
         } else {
             $element->label = $this->_text->get('label.' . $element->key);
         }
     }
     // set error
     if ($error = $element->error()) {
         // create  errormessage
         $element->error = $this->_text->get('error.' . $element->key . '.' . $error);
     } else {
         $element->error = FALSE;
     }
     // set comment
     if (!isset($element->comment)) {
         if ($comment = $this->_text->get('comment.' . $element->key)) {
             $element->comment = $comment;
         } else {
             $element->comment = FALSE;
         }
     }
     // set default view
     $view = 'form/element';
     // render the element itself
     switch ($element->type) {
         case 'radio':
         case 'checkbox':
         case 'select':
             if (Arr::is_assoc($element->options) === FALSE) {
                 $options = array();
                 foreach ($element->options as $value => $label) {
                     $value = $label;
                     $label = $this->_text->get('option.' . $element->key . '.' . $value);
                     $options[$value] = $label;
                 }
                 $element->options = $options;
             }
             if ($element->type === 'radio') {
                 $view = 'form/radio';
             }
             if ($element->type === 'checkbox') {
                 $view = 'form/checkbox';
             }
             if ($element->type === 'select') {
                 if (isset($element->first_option)) {
                     $option = $element->first_option;
                     $value = is_array($option) && isset($option['value']) ? $option['value'] : $option;
                     $label = is_array($option) && isset($option['label']) ? $option['label'] : $this->_text->get('option.' . $element->key . '.' . $value);
                     // add to the beginning of options
                     $reverse = array_reverse($element->options, TRUE);
                     $reverse[$value] = $label;
                     $element->options = array_reverse($reverse, TRUE);
                 }
                 // set bootstap class
                 $attributes['class'] .= ' form-control';
                 $element->html = FormHTML::select($element->name, $element->options, $element->value, $attributes);
             }
             break;
         case 'hidden':
             $view = FALSE;
             $element->html = FormHTML::hidden($element->name, $element->value, $attributes);
             break;
         case 'submit':
             $view = FALSE;
             $label = isset($element->label) ? $element->label : $this->_text->get('label.' . $element->key);
             $element->html = FormHTML::submit($element->name, $label, $attributes);
             break;
         case 'btn':
             $view = FALSE;
             $label = isset($element->label) ? $element->label : $this->_text->get('label.' . $element->key);
             $href = isset($element->href) ? $element->href : '#';
             $element->html = HTML::anchor($href, $label, $attributes);
             break;
         case 'button':
             $view = FALSE;
             $label = isset($element->label) ? $element->label : $this->_text->get('label.' . $element->key);
             $element->html = FormHTML::button($element->name, $label, $attributes);
             break;
         case 'file':
             $element->html = FormHTML::file($element->name, $attributes);
             break;
         case 'image':
             $element->html = FormHTML::image($element->name, $element->value, $attributes, FALSE);
             break;
         case 'text':
         case 'password':
             if (!isset($attributes['placeholder'])) {
                 $attributes['placeholder'] = $this->_text->get('placeholder.' . $element->key);
             }
             // set bootstap class
             $attributes['class'] .= ' form-control';
             if ($element->type === 'text') {
                 $element->html = FormHTML::input($element->name, $element->value, $attributes);
             }
             if ($element->type === 'password') {
                 $element->html = FormHTML::password($element->name, $element->value, $attributes);
             }
             break;
         case 'textarea':
             $attributes['class'] .= ' form-control';
             $element->html = FormHTML::textarea($element->name, $element->value, $attributes, FALSE);
             break;
         default:
             $element->html = View::factory('form/' . $element->type, array('viewer' => $this, 'element' => $element))->render();
     }
     // wrap element
     if ($view) {
         $html = View::factory($view, array('element' => $element))->render();
     } else {
         $html = $element->html;
     }
     return $html;
 }
echo text('label.time_show_start');
?>
		</label>
		<div class="yf-date">
			<?php 
echo View::factory('form/date', array('element' => (object) array('time' => TRUE, 'name' => $element->name . '[time_show_start]', 'value' => isset($element->value['time_show_start']) ? $element->value['time_show_start'] : date('Y-m-d H:i:s', time()))));
?>
		</div>
	</div>



	<div class="yf-end col-md-6">
		<label>
			<?php 
echo FormHTML::checkbox($element->name . '[use_time_show_end]', '1', $element->value['use_time_show_end'] == '1', array('class' => 'yf-use'));
?>
 
			<?php 
echo text('label.time_show_end');
?>
		</label>

		<div class="yf-date">
			<?php 
echo View::factory('form/date', array('element' => (object) array('time' => TRUE, 'name' => $element->name . '[time_show_end]', 'value' => isset($element->value['time_show_end']) ? $element->value['time_show_end'] : date('Y-m-d H:i:s', time()))));
?>
		</div>
	</div>

</div>
<div class="yf" data-use="backend.form.Link" data-settings='<?php 
echo json_encode(array('url_create' => URL::to('Link@create', array('viewport' => 'item', 'callback' => '{{callback}}')), 'url_update' => URL::to('Link@update:{{id}}', array('viewport' => 'item', 'callback' => '{{callback}}')), 'url_delete' => URL::to('Link@delete:{{id}}'), 'url_json' => URL::to('Link@json:{{id}}')));
?>
'>
	
	<script class="yf-template" type="text/html">
		<div>
			<span>{{title}</span><br />
			<span>{{url}}</span>
		</div>
	</script>

	<?php 
echo FormHTML::hidden($element->name, $element->value, array('class' => 'yf-value'));
?>

	<div class="section">
		<?php 
echo HTML::anchor('#', text('label.link_create'), array('class' => 'yf-create btn btn-default btn-md', 'title' => text('label.link_create')));
?>
		<div class="pull-right">
			<?php 
echo HTML::anchor('#', '<span class="glyphicon glyphicon-pencil"></span>', array('class' => 'yf-update btn btn-default btn-xs', 'title' => text('label.link_update')));
echo HTML::anchor('#', '<span class="glyphicon glyphicon-trash"></span>', array('class' => 'yf-delete  btn btn-default btn-xs', 'title' => text('label.link_delete'), 'data-question' => text('question.link_delete')));
?>
		</div>
		<div class="yf-preview"></div>
	</div>
</div>
<div class="yf  form-inline" data-use="backend.form.Item" data-settings='<?php 
echo json_encode(array('url_create' => URL::to('{{module}}@list', array('viewport' => 'module', 'task' => 'select', 'callback' => '{{callback}}')), 'url_update' => URL::to('{{module}}@list:{{id}}', array('viewport' => 'module', 'task' => 'select', 'callback' => '{{callback}}')), 'url_json' => URL::to('{{module}}@json:{{id}}')));
?>
'>
	
	<?php 
echo FormHTML::hidden($element->name . '[item_id]', $element->value['item_id'], array('class' => 'yf-item_id'));
?>
	
	<?php 
echo FormHTML::hidden($element->name . '[params]', isset($element->value['params']) && !empty($element->value['params']) ? json_encode($element->value['params']) : '{}', array('class' => 'yf-params'));
?>
	
	<?php 
echo FormHTML::hidden($element->name . '[request]', $element->value['request'], array('class' => 'yf-request'));
?>
	
	<div class="section">
		<div class="form-group">
			<select class="yf-item-module form-control" name="<?php 
echo $element->name . '[module]';
?>
">
				<?php 
foreach ($element->modules as $value => $label) {
    ?>
					<option value="<?php 
    echo $value;
    ?>
" <?php 
    echo $element->value['module'] == $value && $element->value['request'] == '' ? 'selected' : '';
<div class="yf" data-use="backend.form.Upload">
	<?php 
for ($i = 0; $i < $element->amount; $i++) {
    ?>
		<?php 
    echo FormHTML::file($element->name, array('multiple' => 'multiple'));
    ?>
<br /><br />
	<?php 
}
?>
</div>
<div class="imageEmbed">

	<script class="imageEmbeddedTemplate" type="text/x-jquery-tmpl">
		<img src=<?php 
echo $_path['files'] . 'images/admin/';
?>
${file} width="90" height="90" />
	</script>
	
	<?php 
echo FormHTML::hidden($element->name . '[id]', $element->value['id'], array('class' => 'imageId'));
?>
	<?php 
echo FormHTML::hidden($element->name . '[file]', $element->value['file'], array('class' => 'imageFile'));
?>
	<?php 
echo FormHTML::hidden($element->name . '[title]', $element->value['title'], array('class' => 'imageTitle'));
?>
	
	<div class="imageEmbedded">
	</div>
	
		<?php 
echo HTML::anchor(Route::url($_route, array('mode' => 'browse', 'task' => 'select', 'controller' => $element->controller)), '<span>' . text($element->controller . ':label.browse') . '</span>', array('class' => 'browse btn'));
?>
</div>

<script type="text/javascript">yf.library('form.image.internal');</script>
<?php

View::asset('js', URL::get('vendor') . 'tinymce/tinymce.min.js');
View::asset('js', URL::get('library') . 'js/backend/tinymce/yflink/plugin.js');
View::asset('js', URL::get('library') . 'js/backend/tinymce/yfimage/plugin.js');
View::asset('template', '<script class="yf" name="tinymce-image-default" type="text/html">
<img align="left" data-id="{{id}}" src="{{src}}" alt="{{title}}" data-size="{{size}}" data-enlarge="{{enlarge}}" />
</script>');
?>
<!-- Text area -->
<span class="yf" data-use="backend.form.Tinymce" data-template="tinymce-image-default" data-settings='<?php 
echo json_encode(array('tinymce' => array('mode' => 'textareas', 'selector' => '', 'content_css' => URL::get('base') . 'style/css/default.css,' . URL::get('base') . 'style/css/style.css,' . URL::get('base') . 'style/css/wysiwyg.css', 'convert_urls' => FALSE, 'force_p_newlines' => FALSE, 'language' => $_language, 'paste_word_valid_elements' => 'b,strong,i,em,h1,h2', 'menubar' => 'edit, insert, view, format, table', 'valid_elements' => 'object[height|width|style|data|type],param[name|value|style],embed[src|type|allowscriptaccess|allowfullscreen|width|height],span[name|value|style],strong/b,em/i,u/underline,a[href|target|id|class|title|data-id|style],p[style],h2[style],h3[style],hr[style],br,ul[style],ol[style],li[style],img[src|alt|title|align|width|height|id|class|rel|data-size|data-id|data-enlarge|style],table[style|width|height],tr[width|height],td[width|height|rowspan|colspan],th,tbody,sub,sup,iframe[src|width|height|frameborder|style],pre[style],div[class|style],blockquote[class|style],code[class|style]', 'toolbar1' => 'undo redo | styleselect | bold italic | bullist numlist | yflink yfimage | code', 'width' => '100%', 'height' => 400, 'plugins' => 'paste,media,table,yfimage,yflink,code'), 'url_link' => URL::to((isset($element->controller_link) ? $element->controller_link : 'link') . '@{{action}}:{{id}}', array('viewport' => 'item', 'callback' => '{{callback}}')), 'title_link' => text('link:module.single'), 'url_image' => URL::to((isset($element->controller_image) ? $element->controller_image : 'image') . '@embed:{{id}}', array('viewport' => 'item', 'param1' => '{{size}}', 'callback' => '{{callback}}')), 'title_image' => text('image:module.single'), 'path_images' => URL::get('files') . 'images/'));
?>
'>
	
	<?php 
echo FormHTML::textarea($element->name, HTML::chars($element->value), $element->attributes, FALSE);
?>
</span>
	<!-- backup: when js fails, the original values will not be lost -->
	<!-- hidden will be removed directly when js loads -->
	<?php 
foreach ($values as $value) {
    ?>
		<?php 
    echo FormHTML::hidden($element->name, $value, array('class' => 'yf-value-backup'));
    ?>
	<?php 
}
?>
	
	<!-- value template -->
	<script class="yf-template-backup" type="text/html">
		<?php 
echo FormHTML::hidden($element->name, '{{value}}', array('class' => 'yf-value-backup'));
?>
	</script>
	
	<!-- item template -->
	<script class="yf-template" type="text/html">
		<div class="yf-item item">
			<input type="hidden" name="<?php 
echo $element->name;
?>
" value='{{id}}' />
			<div class="pull-right">
				<a href="#" class="yf-update btn btn-default btn-xs" title="<?php 
echo text('label.update') . ' ' . text($element->controller . ':module.single', array(), FALSE);
?>
"><span class="glyphicon glyphicon-pencil"></span></a>