Example #1
0
 /**
  * Renders the object
  *
  * @return string
  */
 public function render()
 {
     $input = $this->form->input($this->type, $this->name, $this->value, $this->options);
     if (!$this->label) {
         return (string) $input;
     }
     $attributes = new Attributes($this->attributes, ['class' => $this->type]);
     $input .= '<span>' . $this->label . '</span>';
     $label = '<label>' . $input . '</label>';
     return "<div {$attributes}>{$label}</div>";
 }
Example #2
0
File: tag.php Project: anqh/core
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        echo Form::open();
        ?>

<fieldset>

	<?php 
        echo Form::control_group(Form::input('name', $this->tag->name, array('class' => 'input-xxlarge', 'maxlength' => 32)), array('name' => __('Name')), Arr::get($this->errors, 'name'));
        ?>

	<?php 
        echo Form::control_group(Form::input('description', $this->tag->description, array('class' => 'input-xxlarge')), array('description' => __('Short description')), Arr::get($this->errors, 'description'));
        ?>

</fieldset>

<fieldset class="form-actions">
	<?php 
        echo Form::button('save', __('Save'), array('type' => 'submit', 'class' => 'btn btn-success btn-large'));
        ?>
	<?php 
        echo HTML::anchor(Request::back(Route::url('tags'), true), __('Cancel'), array('class' => 'cancel'));
        ?>
</fieldset>

<?php 
        echo Form::close();
        return ob_get_clean();
    }
Example #3
0
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        $tags = $this->group->tags();
        if (empty($tags)) {
            ?>

<div class="empty">
	<?php 
            echo __('No tags yet.');
            ?>
</div>

<?php 
        } else {
            ?>

<ul>
	<?php 
            foreach ($tags as $tag) {
                ?>
	<li><?php 
                echo HTML::anchor(Route::model($tag), $tag->name);
                ?>
</li>
	<?php 
            }
            ?>
</ul>

<?php 
        }
        echo Form::open();
        ?>

<fieldset>

	<?php 
        echo Form::control_group(Form::input('name', $this->group->name, array('class' => 'input-xxlarge', 'maxlength' => 32)), array('name' => __('Name')), Arr::get($this->errors, 'name'));
        ?>

	<?php 
        echo Form::control_group(Form::input('description', $this->group->description, array('class' => 'input-xxlarge')), array('description' => __('Short description')), Arr::get($this->errors, 'description'));
        ?>

</fieldset>

<fieldset class="form-actions">
	<?php 
        echo Form::button('save', __('Save'), array('type' => 'submit', 'class' => 'btn btn-success btn-large'));
        ?>
	<?php 
        echo HTML::anchor(Request::back(Route::url('tags'), true), __('Cancel'), array('class' => 'cancel'));
        ?>
</fieldset>

<?php 
        echo Form::close();
        return ob_get_clean();
    }
Example #4
0
File: edit.php Project: anqh/blog
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        echo Form::open();
        ?>

		<fieldset>
			<?php 
        echo Form::control_group(Form::input('name', $this->blog_entry->name, array('class' => 'input-xxlarge')), array('name' => __('Title')), Arr::get($this->errors, 'name'));
        ?>

			<?php 
        echo Form::control_group(Form::textarea_editor('content', $this->blog_entry->content, array('class' => 'input-xxlarge'), true), array('content' => __('Content')), Arr::get($this->errors, 'content'));
        ?>
		</fieldset>

		<fieldset class="form-actions">
			<?php 
        echo Form::csrf();
        ?>
			<?php 
        echo Form::button('save', __('Save'), array('type' => 'submit', 'class' => 'btn btn-success btn-large'));
        ?>
			<?php 
        echo $this->cancel ? HTML::anchor($this->cancel, __('Cancel'), array('class' => 'cancel')) : '';
        ?>
		</fieldset>

<?php 
        echo Form::close();
        return ob_get_clean();
    }
Example #5
0
 public function view()
 {
     // Group's inputs.
     $name_group_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('name', $this->requested_aircraft->name, ['class' => 'form-control', 'type' => 'text']), 'label' => 'A/C Name'], false)];
     $general_group_1_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('basic_empty_weight', $this->requested_aircraft->basic_empty_weight, ['class' => 'form-control', 'type' => 'number']) . "kg", 'label' => 'Basic Empty Weight'], false), View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('cg_position', $this->requested_aircraft->cg_position, ['class' => 'form-control', 'type' => 'number']) . "aft of datum", 'label' => 'C of G Position'], false)];
     $description_group_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-12', 'input_coltype' => 'col-xs-12', 'input' => Form::textarea('description', $this->requested_aircraft->description, ['class' => 'form-control']), 'label' => 'Description', 'label_left' => true], false)];
     $weight_limits_group_1_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('max_ramp_weight', $this->requested_aircraft->max_ramp_weight, ['class' => 'form-control', 'type' => 'text']), 'label' => 'Max Ramp Weight'], false), View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('mctow', $this->requested_aircraft->mctow, ['class' => 'form-control', 'type' => 'text']), 'label' => 'MCTOW'], false)];
     $weight_limits_group_2_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('mlw', $this->requested_aircraft->mlw, ['class' => 'form-control', 'type' => 'text']), 'label' => 'MLW'], false), View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('mzfw', $this->requested_aircraft->mzfw, ['class' => 'form-control', 'type' => 'text']), 'label' => 'MZFW'], false)];
     $arms_table_template = View::forge('widgets/tablewithactions/template', ['duplicate_action' => false, 'cells' => [View::forge('widgets/tablewithactions/row/cell', ['cell_content' => Form::input('_name', '', ['class' => 'form-control'])], false), View::forge('widgets/tablewithactions/row/cell', ['cell_content' => Form::input('_position', '', ['class' => 'form-control'])], false), View::forge('widgets/tablewithactions/row/cell', ['cell_content' => Form::input('_value', '', ['class' => 'form-control']) . Form::hidden('_type', 'arm')], false)]]);
     $arms_table = View::forge('widgets/tablewithactions', ['template_row' => $arms_table_template, 'name' => '_arms', 'coltype' => 'col-xs-12 col-md-6', 'headings' => ['<th>Label</th>', '<th>Arm (aft of datum)</th>', '<th>Max Weight</th>'], 'rows' => $this->arms_table_rows], false);
     $cglimits_table_template = View::forge('widgets/tablewithactions/template', ['duplicate_action' => false, 'cells' => [View::forge('widgets/tablewithactions/row/cell', ['cell_content' => Form::input('_position', '', ['class' => 'form-control'])], false), View::forge('widgets/tablewithactions/row/cell', ['cell_content' => Form::input('_value', '', ['class' => 'form-control']) . Form::hidden('_type', 'maxweight') . Form::hidden('_name', 'limit')], false)]]);
     $cglimits_table = View::forge('widgets/tablewithactions', ['template_row' => $cglimits_table_template, 'name' => '_arms', 'coltype' => 'col-xs-6', 'headings' => ['<th>Arm (aft of datum)</th>', '<th>Weight Limit</th>'], 'rows' => $this->cglimits_table_rows], false);
     $button_group_1_inputs = [Asset::js('tablewithactions.js', false), View::forge('form/button', ['coltype' => 'col-xs-offset-5 col-xs-2', 'link' => 'submit/aircraft/' . $this->id, 'response_target' => './aircraft_form', 'class' => 'form-control btn-success', 'label' => 'Save Changes'], false)];
     // Headings
     $general_heading = View::forge('form/heading', ['text' => 'General', 'size' => 4], false);
     $weight_limits_heading = View::forge('form/heading', ['text' => 'Weight Limits', 'size' => 4], false);
     $arms_heading = View::forge('form/heading', ['text' => 'Arms', 'size' => 4], false);
     $cg_limits_heading = View::forge('form/heading', ['text' => 'C of G Limits', 'size' => 4], false);
     // Groups
     $name_group = View::forge('form/group', ['inputs' => $name_group_inputs], false);
     $general_group_1 = View::forge('form/group', ['inputs' => $general_group_1_inputs], false);
     $description_group = View::forge('form/group', ['inputs' => $description_group_inputs], false);
     $weight_limits_group_1 = View::forge('form/group', ['inputs' => $weight_limits_group_1_inputs]);
     $weight_limits_group_2 = View::forge('form/group', ['inputs' => $weight_limits_group_2_inputs]);
     $buttons_group = View::forge('form/group', ['inputs' => $button_group_1_inputs], false);
     $cg_limits_group = View::forge('form/group', ['inputs' => ['<div class="col-xs-6">' . $cglimits_table . '</div>' . '<div class="col-xs-6">' . 'Graph here' . '</div>']], false);
     $weightandbalance_section_data = ['heading' => 'Weight and Balance Data', 'unique_id' => Str::random('uuid'), 'groups' => [$general_heading, $name_group, $general_group_1, $description_group, $weight_limits_heading, $weight_limits_group_1, $weight_limits_group_2, $arms_heading, $arms_table, $cg_limits_heading, $cg_limits_group, $buttons_group]];
     $weightandbalance_section = View::forge('form/section', $weightandbalance_section_data, false);
     $this->aircraft_form = $weightandbalance_section;
 }
Example #6
0
File: report.php Project: anqh/anqh
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        $gallery = $this->image->gallery();
        echo Form::open(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $this->image->id, 'action' => 'report')), array('class' => Request::current()->is_ajax() ? 'ajaxify' : ''));
        ?>

<fieldset>

	<?php 
        echo Form::control_group(Form::input('reason', null, array('class' => 'input-block-level')), array('name' => __('Reason')), null, __('You can enter an optional reason for reporting this image, e.g. why it should be removed'));
        ?>

</fieldset>

<fieldset class="form-actions">
	<?php 
        echo Form::button('save', __('Report'), array('type' => 'submit', 'class' => 'btn btn-danger btn-large'));
        ?>
	<?php 
        echo Request::current()->is_ajax() ? '' : HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $this->image->id, 'action' => '')), __('Cancel'), array('class' => 'cancel'));
        ?>

	<?php 
        echo Form::csrf();
        ?>
</fieldset>

<?php 
        return ob_get_clean();
    }
Example #7
0
 public static function displayForm($value, &$settings, $model)
 {
     $settings = static::settings($settings);
     if (!is_array($value)) {
         $value = array();
     }
     // Search input or
     $searchInput = \Form::input($settings['mapping']['fieldName'] . '[search]', null, array('class' => 'input input-xxlarge search-input', 'placeholder' => \Lang::get('admin.common.map_search_placeholder')));
     $searchButton = \Form::button('mapsearch', \Lang::get('admin.verbs.search'), array('class' => 'btn btn-primary'));
     $searchInput = html_tag('div', array('class' => 'form form-inline search-form'), $searchInput . $searchButton);
     // Hidden inputs
     $latInput = \Form::hidden($settings['mapping']['fieldName'] . '[lat]', \Arr::get($value, 'lat'), array('class' => 'lat'));
     $lngInput = \Form::hidden($settings['mapping']['fieldName'] . '[lng]', \Arr::get($value, 'lng'), array('class' => 'lng'));
     $zoomInput = \Form::hidden($settings['mapping']['fieldName'] . '[zoom]', \Arr::get($value, 'zoom'), array('class' => 'zoom'));
     // Other elements
     $required = isset($settings['required']) ? $settings['required'] : false;
     $label_text = $settings['title'] . ($required ? ' *' : '');
     $label = \Form::label($label_text);
     $mapDiv = html_tag('div', array('class' => 'map', 'id' => \Inflector::friendly_title($settings['mapping']['fieldName'], '-', true) . '-bing-map'), ' ');
     // Check that we have an API key
     if (empty($settings['api_key'])) {
         $content = $label . '<div class="well"><p>' . \Lang::get('admin.bing.api_key_not_set') . '</p></div>';
     } else {
         $content = $label . $searchInput . $latInput . $lngInput . $zoomInput . $mapDiv;
     }
     $content = html_tag('div', array('class' => 'controls control-group field-type-bing-map', 'data-field-name' => $settings['mapping']['fieldName']), $content);
     return array('content' => $content, 'js_data' => $settings);
 }
Example #8
0
 public static function input($type, $name, $options = array())
 {
     $value = Form::getValueAttribute($name);
     //Si el valor es un numero, redondear 5 decimales.
     if (is_numeric($value)) {
         $value = round($value, 5);
     }
     //Si el modelo ya tiene este atributo se le da importancia.
     if ($value != null) {
         $options['value'] = $value;
     }
     $full_name = self::getName($name);
     $id = self::getClass($name);
     if (isset($options['class']) && $options['class'] != '') {
         //Si ya tiene clase se añade la generada a la lista de clases
         $options['class'] = $options['class'] . ' ' . $id;
     } else {
         //Si no se usa esta clase como única
         $options['class'] = $id;
     }
     if (!self::$is_array && !isset($options['id'])) {
         //Si el modelo es unico y no existe id.
         $options['id'] = $id;
     }
     return Form::input($type, $full_name, $value, $options);
 }
Example #9
0
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        echo $this->message;
        echo Form::open();
        echo Form::control_group(Form::input('email', $this->email, array('class' => 'input input-xxlarge', 'placeholder' => __('Username or email'))), array('email' => __('Send my new password to')), null, __('We will send you a "new" password generated from your old forgotten password.<br /><em>Please change your password after signing in!</em>'));
        echo Form::button(null, '<i class="icon-envelope icon-white"></i> ' . __('Send'), array('class' => 'btn btn-primary'));
        echo Form::close();
        ?>

<hr />

<blockquote cite="http://dilbert.com/strips/comic/1996-09-05/">
	<dl class="dl-horizontal">
		<dt>Asok:</dt> <dd>I have forgotten my password. I humbly beg for assistance.</dd>
		<dt>Dogbert:</dt> <dd>I have no time for boring administrative tasks, you fool! I'm too busy upgrading the network.</dd>
		<dt>Asok:</dt> <dd>You could have given me a new password in the time it took to belittle me.</dd>
		<dt>Dogbert:</dt> <dd>Yeah, but which option would give me job satisfaction?</dd>
	</dl>
	<small class="pull-right"><a href="http://dilbert.com/strips/comic/1996-09-05/">Dilbert</a></small>
</blockquote>

<?php 
        return ob_get_clean();
    }
Example #10
0
 public function form_columns()
 {
     return array('id' => array('type' => 'input', 'editable' => FALSE), 'name' => array('type' => 'input'), 'job' => array('type' => 'select', 'choices' => array($this, 'get_types')), 'date_start' => array('type' => function ($object, $field, $attributes) {
         return Form::input($field, $object->date_start(), $attributes);
     }), 'date_end' => array('type' => function ($object, $field, $attributes) {
         return Form::input($field, $object->date_end(), $attributes);
     }));
 }
Example #11
0
 public function input($name, array $attr = NULL)
 {
     if (is_array($this->choices)) {
         return Form::select($name, $this->choices, $this->value, $attr);
     } else {
         return Form::input($name, $this->verbose(), $attr);
     }
 }
Example #12
0
 public function testInput()
 {
     $data = Form::input('text');
     $this->assertEquals('<input type="text"/>', $data);
     $data = Form::input('email', '*****@*****.**');
     $this->assertEquals('<input type="email" value="*****@*****.**"/>', $data);
     $data = Form::input('email', '*****@*****.**', ['id' => 'ID', 'class' => 'Class']);
     $this->assertEquals('<input type="email" value="*****@*****.**" id="ID" class="Class"/>', $data);
 }
Example #13
0
 public function view()
 {
     $form_sections = [View::forge('form/group', ['inputs' => [View::forge('form/group/input', ['label' => 'Flight Record or Manifest ID', 'label_left' => true, 'label_coltype' => 'col-xs-12', 'input_coltype' => 'col-xs-12', 'input' => Form::input('id', '', ['class' => 'form-control'])], false)]], false)];
     $form = View::forge('form/container', ['name' => 'start', 'sections' => $form_sections, 'buttons' => [View::forge('form/button', ['label' => 'GO!', 'link' => 'view/search', 'class' => 'btn btn-success', 'coltype' => 'col-xs-offset-5 col-xs-2'], false), View::forge('form/button', ['label' => 'test!', 'link' => 'view/manifest', 'class' => 'btn btn-success', 'coltype' => 'col-xs-offset-5 col-xs-2'], false)]], false);
     $panel_content = '<img src="http://skylineaviation.co.nz/assets/img/skyline-aviation-logo.svg" style="margin:10px auto 20px auto;width:50%"></img>';
     $panel_content .= $form;
     $panel = View::forge('layout/panel_simple', ['content' => $panel_content], false);
     $this->start = $panel;
 }
Example #14
0
 public function input($name, array $attr = array())
 {
     $attr['type'] = 'file';
     $r = Form::input($name, '', $attr);
     if ($this->value != '') {
         $r .= HTML::image($this->__toString());
     }
     return $r;
 }
Example #15
0
 public static function li_input($input, $text = NULL, $value = NULL, array $attributes = array(), $error = "")
 {
    $atts = array_merge($attributes, array('id'=>$input));
    echo "<li class=\"input_field input_text\">";
    echo Form::label($input, $text);
    echo Form::input($input, $value, $atts);
    echo "<span class=\"error\">$error</span>";
    echo "</li>";
 }
Example #16
0
 /**
  * Renders the Searchbox object to a string. 
  * 
  * @return   string
  */
 public function render()
 {
     $elements[] = '<div ' . Html::attributes($this->get_option('attributes')) . '>';
     $elements[] = Form::input($this->_name . '_searchbox_string', $this->_search_string, $this->get_option('search_field_attributes'));
     $elements[] = Form::button($this->_name . '_searchbox_string', $this->get_option('search_button_label', __('Search')), $this->get_option('search_button_attributes'));
     $elements[] = '<div ' . Html::attributes($this->get_option('result_box_attributes')) . '>';
     $elements[] = '</div>';
     return "\n" . implode("\n", $elements) . "\n";
 }
Example #17
0
 public function render()
 {
     if ($this->_config['maxlength'] and !isset($this->_attributes['maxlength'])) {
         $this->_attributes['maxlength'] = $this->_extra[$this->_config['maxlength']];
     }
     if ($this->_config['multiline']) {
         return Form::textarea($this->_name, $this->_value, $this->_attributes + array('id' => $this->_id, 'rows' => $this->_config['multiline'], 'cols' => 120, 'class' => 'xxlarge'));
     }
     return Form::input($this->_name, $this->_value, $this->_attributes + array('id' => $this->_id, 'size' => 40));
 }
Example #18
0
 public function input($name, $value, array $attr = NULL)
 {
     // Make the value verbose
     $value = $this->verbose($value);
     if (is_array($this->choices)) {
         return Form::select($name, $this->choices, $value, $attr);
     } else {
         return Form::input($name, $value, $attr);
     }
 }
Example #19
0
 public function input($name, $attributes = NULL)
 {
     $input = Facebook_Stream::$input_prefix . $name . Facebook_Stream::$input_suffix;
     if ($name == 'attachment') {
         return $this->_attachment->inputs($attributes);
     }
     if ($this->_inputs[$name]['hidden']) {
         return Form::hidden($input, $this->_stream[$name], $attributes);
     }
     return Form::input($input, $this->_stream[$name], $attributes);
 }
Example #20
0
File: date.php Project: raku/MorCMS
 /**
  * input for filter
  * @param string $value
  * @return string form::select 
  */
 public function input_filter($value)
 {
     if (isset($this->item['format'])) {
         //costom date format
         $value = date($this->item['format'], $value);
     } else {
         //default date format
         $value = date('Y.m.d H:i:s', $value);
     }
     return Form::input($this->item['name'], $value . ' - ' . date('Y.m.d H:i:s'), array('class' => 'datepicker'));
 }
Example #21
0
 public function input($name, $attributes = NULL)
 {
     $input = Facebook_Attachment::$input_prefix . $name . Facebook_Attachment::$input_suffix;
     if ($name == 'media') {
         return $this->_media_type($input, $attributes);
     }
     if ($this->_inputs[$name]['hidden']) {
         return '';
         //Form::hidden($input, $this->_attachment[$name], $attributes);
     }
     return Form::input($input, $this->_attachment[$name], $attributes);
 }
Example #22
0
 public function buildControl($type, $name, $value = null, $attibutes = array(), $options = array())
 {
     switch ($type) {
         case 'select':
             return \Form::select($name, $options, $value, $attributes);
         case 'password':
             return \Form::password($name);
         case 'checkbox':
             return \Form::checkbox($name);
         default:
             return \Form::input($type, $name, $value);
     }
 }
Example #23
0
 protected function _media_type($input, $attributes)
 {
     $type = Facebook_Attachment::$input_prefix . 'media-type' . Facebook_Attachment::$input_suffix;
     $src = Facebook_Attachment::$input_prefix . 'media-src' . Facebook_Attachment::$input_suffix;
     $upload = Facebook_Attachment::$input_prefix . 'upload' . Facebook_Attachment::$input_suffix;
     $href = Facebook_Attachment::$input_prefix . 'media-href' . Facebook_Attachment::$input_suffix;
     $out = array();
     $out[] = Form::hidden($type, 'image');
     $out[] = strtr(Facebook_Stream::$form_template, array(':label' => Form::label($src, 'Image Location URL', $attributes), ':description' => 'Each record must contain a src key, which maps to the photo URL', ':input' => Form::input($src, NULL, $attributes)));
     $out[] = strtr(Facebook_Stream::$form_template, array(':label' => Form::label($upload, 'Image Upload', $attributes), ':description' => 'Upload a file to use as the image src', ':input' => Form::file($upload, $attributes)));
     $out[] = strtr(Facebook_Stream::$form_template, array(':label' => Form::label($href, 'Image Hyperlink Destination', $attributes), ':description' => 'Maps to the URL where a user should be taken if he or she clicks the photo.', ':input' => Form::input($href, NULL, $attributes)));
     return implode("\n", $out);
 }
Example #24
0
 /** inheritdoc */
 public static function displayForm($value, &$settings, $model)
 {
     $required = isset($settings['required']) ? $settings['required'] : false;
     $errors = $model->getErrorsForField($settings['mapping']['fieldName']);
     $has_errors = count($errors) > 0;
     $input_attributes = array('class' => 'input input-xxlarge');
     $attributes = array('class' => 'field-type-link controls control-group' . ($has_errors ? ' error' : ''));
     $href_name = $settings['mapping']['fieldName'] . '[href]';
     $value['href'] = isset($value['href']) ? $value['href'] : null;
     $label_text = $settings['title'] . ($required ? ' *' : '');
     // Translation?
     if (\CMF::$lang_enabled && !\CMF::langIsDefault() && isset($settings['mapping']['columnName']) && $model->isTranslatable($settings['mapping']['columnName'])) {
         // If there is no translation
         if (!$model->hasTranslation($settings['mapping']['columnName'])) {
             $attributes['class'] .= ' no-translation';
             $input_attributes['class'] .= ' no-translation';
             $label_text = '<img class="lang-flag" src="' . \Uri::create('/admin/assets/img/lang/' . \CMF::defaultLang() . '.png') . '" />&nbsp; ' . $label_text;
         } else {
             $label_text = '<img class="lang-flag" src="' . \Uri::create('/admin/assets/img/lang/' . \CMF::lang() . '.png') . '" />&nbsp; ' . $label_text;
         }
     }
     // EXTERNAL CHECKBOX
     $external_name = $settings['mapping']['fieldName'] . '[external]';
     $external_value = \Arr::get($value, 'external', false);
     $external = \Form::hidden($external_name, '0') . html_tag('label', array('class' => 'checkbox external-checkbox'), \Form::checkbox($external_name, '1', $external_value, array()) . ' custom');
     $label = \Form::label($label_text . ($has_errors ? ' - ' . $errors[0] : ''), $href_name, array('class' => 'item-label')) . $external . html_tag('div', array('class' => 'clear'), '&nbsp;');
     if ($external_value) {
         $attributes['class'] .= ' external';
     }
     // EXTERNAL INPUT CONTENT
     $href_value_ext = $external_value ? $value['href'] : '';
     $ext_input = \Form::input($href_name, $href_value_ext, $input_attributes);
     $ext_content = html_tag('div', array('class' => 'external-link'), $ext_input);
     // INTERNAL DROPDOWN CONTENT
     $options = static::getOptions($settings, $model);
     $href_value_int = $external_value ? '' : $value['href'];
     // Check if the value is actually an alias
     if (!empty($href_value_int)) {
         $url_value = \CMF\Model\URL::find($href_value_int);
         if ($url_value && ($alias = $url_value->alias)) {
             $href_value_int = $alias->id;
         }
     }
     $input = \Form::select($href_name, $href_value_int, $options, $input_attributes);
     $int_content = html_tag('div', array('class' => 'internal-link'), $input);
     return html_tag('div', $attributes, $label . $int_content . $ext_content) . html_tag('div', array(), '');
 }
Example #25
0
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        echo Form::open();
        ?>

<fieldset>
	<legend><?php 
        echo __('Almost there!');
        ?>
</legend>

	<?php 
        echo Form::control_group(Form::input('username', $this->user->userame, array('class' => 'input-small', 'placeholder' => __('JohnDoe'))), array('username' => __('Username')), Arr::get($this->errors, 'username'), __('Choose a unique username with at least <var>:length</var> characters. No special characters, thank you.', array(':length' => Kohana::$config->load('visitor.username.length_min'))));
        ?>

	<?php 
        echo Form::control_group(Form::password('password'), array('password' => __('Password')), Arr::get($this->errors, 'password'));
        ?>

	<?php 
        echo Form::control_group(Form::password('password_confirm'), array('password_confirm' => __('Confirm')), Arr::get($this->errors, 'password_confirm'), __('Try to use letters, numbers and special characters for a stronger password, with at least <var>8</var> characters.'));
        ?>

	<?php 
        echo Form::control_group(Form::input('email', $this->user->email, array('disabled' => 'disabled', 'class' => 'input-xxlarge', 'placeholder' => __('*****@*****.**'))), array('email' => __('Email')), Arr::get($this->errors, 'email'), __('Please remember: sign up is available only with a valid, invited email.'));
        ?>

</fieldset>

<fieldset>
	<?php 
        echo Form::hidden('code', $this->code);
        ?>
	<?php 
        echo Form::button('register', __('Sign up!'), array('type' => 'submit', 'class' => 'btn btn-primary btn-large'));
        ?>
	<?php 
        echo HTML::anchor(Request::back('/', true), __('Cancel'), array('class' => 'cancel'));
        ?>
</fieldset>

<?php 
        echo Form::close();
        return ob_get_clean();
    }
Example #26
0
 public function view()
 {
     $type = str_replace('_id', '', $this->id);
     // Input group
     $name_group_inputs = [Form::hidden($this->id, '_new'), View::forge('form/group/input', ['label' => 'Option Text', 'input' => Form::input('name', '', ['class' => 'form-control'])], false)];
     $name_group = View::forge('form/group', ['inputs' => $name_group_inputs], false);
     // Submit button
     $submit_button = View::forge('form/button', ['label' => 'Add Option', 'link' => 'submit/common_blank', 'class' => 'btn btn-success', 'response_target' => './.', 'custom_attributes' => 'data-dismiss="modal"']);
     // Form build
     $form_container = View::forge('form/container', ['name' => $type, 'sections' => [$name_group], 'buttons' => [$submit_button]]);
     // Create modal body
     $modal_content = View::forge('modal/content', ['title' => 'Add Option', 'body' => $form_container]);
     // Set modal content to configured content.
     $modal_small = View::forge('modal/small', ['content' => $modal_content]);
     // Set the view to the modal ready to send back to client.
     $this->add_modal = $modal_small;
 }
Example #27
0
 /** inheritdoc */
 public static function displayForm($value, &$settings, $model)
 {
     $include_label = isset($settings['label']) ? $settings['label'] : true;
     $target_class = $settings['mapping']['targetEntity'];
     if (is_null($value) || !$value instanceof $target_class) {
         $value = new $target_class();
     }
     // Show a simple alias form if the input var is set
     if (\Input::param('alias', false) !== false) {
         $linkValue = array();
         if (!empty($value)) {
             $linkValue['href'] = $value->isExternal() ? $value->url : strval($value->id);
             $linkValue['external'] = $value->isExternal();
         }
         return \CMF\Field\Object\Link::displayForm($linkValue, $settings, $model);
     }
     $model_class = get_class($model);
     $errors = $model->getErrorsForField($settings['mapping']['fieldName']);
     $has_errors = count($errors) > 0;
     $attributes = array('class' => 'field-type-url controls control-group' . ($has_errors ? ' error' : ''));
     $slug_name = $settings['mapping']['fieldName'] . '[slug]';
     $label_text = $settings['title'] . ($has_errors ? ' - ' . $errors[0] : '');
     if (\CMF::$lang_enabled && !\CMF::langIsDefault()) {
         if (!$value->hasTranslation('slug')) {
             $attributes['class'] .= ' no-translation';
             $label_text = '<img class="lang-flag" src="' . \Uri::create('/admin/assets/img/lang/' . \CMF::defaultLang() . '.png') . '" />&nbsp; ' . $label_text;
         } else {
             $label_text = '<img class="lang-flag" src="' . \Uri::create('/admin/assets/img/lang/' . \CMF::lang() . '.png') . '" />&nbsp; ' . $label_text;
         }
     }
     $keep_updated_setting = 'settings[' . $settings['mapping']['fieldName'] . '][keep_updated]';
     $keep_updated = \Form::hidden($keep_updated_setting, '0', array()) . html_tag('label', array('class' => 'checkbox keep-updated'), \Form::checkbox($keep_updated_setting, '1', \Arr::get($settings, 'keep_updated', true), array()) . strtolower(\Lang::get('admin.common.auto_update')));
     $input = \Form::input($slug_name, $value->slug, array('class' => 'input-xlarge', 'data-copy-from' => implode(',', $model_class::slugFields())));
     $label = !$include_label ? '' : html_tag('label', array('class' => 'item-label', 'for' => $slug_name), $label_text) . $keep_updated . html_tag('div', array('class' => 'clear'), '&nbsp;');
     $prefix = $value->prefix;
     $prepend = html_tag('span', array('class' => 'add-on'), empty($prefix) ? '/' : $prefix);
     $input = html_tag('div', array('class' => 'input-prepend'), $prepend . $input);
     $clear = '<div class="clear"><!-- --></div>';
     if (isset($settings['wrap']) && $settings['wrap'] === false) {
         return $label . $input;
     }
     return html_tag('div', $attributes, $label . $input) . $clear;
 }
 /**
  * @param FormSchema $field
  * @param bool $useLabels
  * @return string the Element to return
  */
 public static function getElement(FormSchema $field, $useLabels = true)
 {
     $returnElement = null;
     $types = \Config::get('formbuilder::config.form-types');
     $options = \Config::get('formbuilder::config.form-options');
     $options = array_key_exists($field->getType(), $options) ? $options[$field->getType()] : null;
     if ($useLabels) {
         $returnElement .= \Form::label($field->getName(), ucfirst($field->getName()));
     }
     if (method_exists('\\Illuminate\\Html\\FormBuilder', $field->getName())) {
         $method = $field->getName();
         $returnElement .= \Form::$method($field->getName(), null);
     } elseif (method_exists('\\Illuminate\\Html\\FormBuilder', $field->getType()) && $field->getType() != 'text') {
         $method = $field->getType();
         $returnElement .= \Form::$method($field->getName(), null);
     } elseif ($field->getType() == 'text') {
         $returnElement .= \Form::textarea($field->getName(), null);
     } else {
         $returnElement .= \Form::input($types[$field->getType()], $field->getName(), $field->getType() == 'boolean' ? 0 : null, $options);
     }
     return $returnElement;
 }
Example #29
0
 /** @inheritdoc */
 public static function displayForm($value, &$settings, $model)
 {
     $settings = static::settings($settings);
     if (!isset($value) || !$value) {
         $value = !is_null($settings['default']) ? \DateTime::createFromFormat($settings['format'], $settings['default']) : new \DateTime();
         if (!is_null($settings['default_offset'])) {
             $value->modify($settings['default_offset']);
         }
     }
     $include_label = isset($settings['label']) ? $settings['label'] : true;
     $required = isset($settings['required']) ? $settings['required'] : false;
     $errors = $model->getErrorsForField($settings['mapping']['fieldName']);
     $has_errors = count($errors) > 0;
     $input_attributes = isset($settings['input_attributes']) ? $settings['input_attributes'] : array('class' => 'input-large');
     $label = !$include_label ? '' : \Form::label($settings['title'] . ($required ? ' *' : '') . ($has_errors ? ' - ' . $errors[0] : ''), $settings['mapping']['fieldName'], array('class' => 'item-label'));
     $input = \Form::input($settings['mapping']['fieldName'], $value->format($settings['format']), $input_attributes);
     $input = $input = html_tag('div', array('class' => 'input-prepend'), html_tag('span', array('class' => 'add-on'), '<i class="fa fa-calendar"></i>') . $input);
     if (isset($settings['wrap']) && $settings['wrap'] === false) {
         return $label . $input;
     }
     return html_tag('div', array('class' => 'controls control-group field-type-datetime' . ($has_errors ? ' error' : '')), $label . $input);
 }
Example #30
0
 public static function input($name, $value = NULL, array $attributes = NULL, $label = NULL, $help = NULL, $inline_help = false)
 {
     $return = '';
     $help = is_null($help) ? '' : ($inline_help ? '<span class="help-inline">' . $help . '</span>' : '<p class="help-block">' . $help . '</p>');
     $label = is_null($label) ? __(ucfirst($name)) : __($label);
     switch (self::$type) {
         case self::HORIZONTAL:
             $attributes['id'] = $name;
             $return .= '<div class="control-group">';
             $return .= parent::label($name, $label, array('class' => 'control-label'));
             $return .= '<div class="controls">';
             $return .= parent::input($name, $value, $attributes);
             $return .= $help;
             $return .= '</div>';
             $return .= '</div>';
             break;
         default:
             $return .= parent::input($name, $value, $attributes);
             $return .= $help;
             break;
     }
     return $return;
 }