Пример #1
0
 public function render($attributes = array())
 {
     $this->setAttributes($attributes);
     $dateFormat = '';
     $format = $this->format ?: 'Y-m-d';
     for ($i = 0; $i < strlen($format); ++$i) {
         switch ($format[$i]) {
             case 'd':
                 $dateFormat .= 'dd';
                 break;
             case 'j':
                 $dateFormat .= 'd';
                 break;
             case 'D':
                 $dateFormat .= 'D';
                 break;
             case 'l':
                 $dateFormat .= 'DD';
                 break;
             case 'z':
                 $dateFormat .= 'o';
                 break;
             case 'F':
                 $dateFormat .= 'MM';
                 break;
             case 'M':
                 $dateFormat .= 'M';
                 break;
             case 'm':
                 $dateFormat .= 'mm';
                 break;
             case 'n':
                 $dateFormat .= 'm';
                 break;
             case 'Y':
                 $dateFormat .= 'yy';
                 break;
             case 'y':
                 $dateFormat .= 'y';
                 break;
             default:
                 $dateFormat .= $format[$i];
         }
     }
     $this->dataDateFormat = $dateFormat;
     $this->dataChangeMonth = $this->change_month;
     $this->dataChangeYear = $this->change_year;
     if ($this->value instanceof \DateTime) {
         $this->value = $this->value->format($format);
     }
     return parent::render();
 }
Пример #2
0
    public function render($attributes = array())
    {
        if (!$this->boolean_value) {
            return parent::render($attributes);
        }
        // Here we use a javascript to switch the hidden value.
        $this->setAttributes($attributes);
        ob_start();
        $fieldId = $this->generateSerialId();
        ?>
<input id="<?php 
        echo $fieldId;
        ?>
" type="hidden" 
            name="<?php 
        echo $this->name;
        ?>
" 
            value="<?php 
        echo $this->checked ? '1' : '0';
        ?>
"/>

        <input 
            <?php 
        echo " data-hidden-id=\"{$fieldId}\" ";
        echo $this->renderAttributes();
        echo $this->checked ? 'checked' : '';
        ?>
        onclick=" 
            var el = document.getElementById('<?php 
        echo $fieldId;
        ?>
');
                el.value = el.value != '1' ? '1' : '0';
                $(el).triggerHandler('change');
        "/><?php 
        $html = ob_get_contents();
        ob_end_clean();
        return $html;
    }
Пример #3
0
    public function render($attributes = array())
    {
        $serial = $this->getSerialId();
        $this->setId($serial);
        ob_start();
        /*
            <style>
            .ui-autocomplete-loading { 
                background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat;
            }
            </style>
            select: function( event, ui ) {
                log( ui.item ?
                    "Selected: " + ui.item.value + " aka " + ui.item.id :
                    "Nothing selected, input was " + this.value );
            }
        */
        ?>
    <script>
    jQuery(function() {
        jQuery( "#<?php 
        echo $serial;
        ?>
" ).autocomplete({
            source: "<?php 
        echo $this->source;
        ?>
",
            minLength: <?php 
        echo $this->min_length;
        ?>
        });
    });
    </script>
        <?php 
        $script = ob_get_contents();
        ob_end_clean();
        return parent::render($attributes) . $script;
    }
Пример #4
0
 public function render($attributes = array())
 {
     $this->setAttributes($attributes);
     $dateFormat = '';
     $timeFormat = '';
     $cursor =& $dateFormat;
     $format = $this->format ?: 'Y-m-d H:i:s';
     $this->dataAmpm = false;
     for ($i = 0; $i < strlen($format); ++$i) {
         switch ($format[$i]) {
             case 'd':
                 $cursor =& $dateFormat;
                 $cursor .= 'dd';
                 break;
             case 'j':
                 $cursor =& $dateFormat;
                 $cursor .= 'd';
                 break;
             case 'D':
                 $cursor =& $dateFormat;
                 $cursor .= 'D';
                 break;
             case 'l':
                 $cursor =& $dateFormat;
                 $cursor .= 'DD';
                 break;
             case 'z':
                 $cursor =& $dateFormat;
                 $cursor .= 'o';
                 break;
             case 'F':
                 $cursor =& $dateFormat;
                 $cursor .= 'MM';
                 break;
             case 'M':
                 $cursor =& $dateFormat;
                 $cursor .= 'M';
                 break;
             case 'm':
                 $cursor =& $dateFormat;
                 $cursor .= 'mm';
                 break;
             case 'n':
                 $cursor =& $dateFormat;
                 $cursor .= 'm';
                 break;
             case 'Y':
                 $cursor =& $dateFormat;
                 $cursor .= 'yy';
                 break;
             case 'y':
                 $cursor =& $dateFormat;
                 $cursor .= 'y';
                 break;
             case 'a':
                 $cursor =& $timeFormat;
                 $cursor .= 'tt';
                 break;
             case 'A':
                 $cursor =& $timeFormat;
                 $cursor .= 'TT';
                 break;
             case 'g':
                 $cursor =& $timeFormat;
                 $cursor .= 'h';
                 $this->dataAmpm = true;
                 break;
             case 'h':
                 $cursor =& $timeFormat;
                 $cursor .= 'hh';
                 $this->dataAmpm = true;
                 break;
             case 'G':
                 $cursor =& $timeFormat;
                 $cursor .= 'h';
                 break;
             case 'H':
                 $cursor =& $timeFormat;
                 $cursor .= 'hh';
                 break;
             case 'i':
                 $cursor =& $timeFormat;
                 $cursor .= 'mm';
                 break;
             case 's':
                 $cursor =& $timeFormat;
                 $cursor .= 'ss';
                 break;
             default:
                 $cursor .= $format[$i];
         }
     }
     $this->dataDateFormat = $dateFormat;
     $this->dataTimeFormat = $timeFormat;
     if ($this->value instanceof \DateTime) {
         $this->value = $this->value->format($format);
     }
     return parent::render();
 }
Пример #5
0
 public function render($attributes = array())
 {
     $html = parent::render($attributes);
     return $html;
 }
Пример #6
0
 public function render($name, $value = null, array $attrs = array())
 {
     if ($value instanceof \DateTime) {
         $value = $value->format($this->format);
     }
     return parent::render($name, $value, $attrs);
 }