/**
     * @param  string $name        The element name
     * @param  string $value       The date displayed in this widget
     * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
     * @param  array  $errors      An array of errors for the field
     *
     * @return string An HTML tag string
     *
     * @see sfWidgetForm
     */
    public function render($name, $value = null, $attributes = array(), $errors = array())
    {
        //return '<input type="text" class="datepicker">';
        $image = '';
        $attributes = array_merge($attributes, $this->getAttributes());
        if (!$this->getOption('inline')) {
            $input = new sfWidgetFormInput(array(), $attributes);
            $html = $input->render($name, $value);
            if (false !== $this->getOption('image')) {
                $image = sprintf('params.buttonImage = "%s"; params.buttonImageOnly = true; params.showOn = "button";', $this->getOption('image'));
            }
        } else {
            $id = $this->generateId($name);
            $html = '<div id="' . $id . '"></div>';
        }
        $id = $this->generateId($name);
        $culture = $this->getOption('culture');
        $html .= <<<EOHTML
<script type="text/javascript">
\t\$(function() {
    // datepicker inicializálás
    \$('#{$id}').datepicker({
      dateFormat: 'yy-mm-dd',
      altField: '#dateStart',
      inline: true,
      showOtherMonths: true
//      minDate: new Date(),
//      defaultDate: \$('#dateStart').val(),
      
    });    
  });      
</script>
EOHTML;
        return $html;
    }
    /**
     * @param  string $name        The element name
     * @param  string $value       The date displayed in this widget
     * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
     * @param  array  $errors      An array of errors for the field
     *
     * @return string An HTML tag string
     *
     * @see sfWidgetForm
     */
    public function render($name, $value = null, $attributes = array(), $errors = array())
    {
        $visibleValue = $this->getOption('value_callback') ? call_user_func($this->getOption('value_callback'), $value) : $value;
        return $this->renderTag('input', array('type' => 'hidden', 'name' => $name, 'value' => $value)) . parent::render('autocomplete_' . $name, $visibleValue, $attributes, $errors) . sprintf(<<<EOF
<script type="text/javascript">
  jQuery(document).ready(function() {
    jQuery("#%s")
    .autocomplete('%s', jQuery.extend({}, {
      dataType: 'json',
      parse:    function(data) {
        var parsed = [];
        for (key in data) {
          parsed[parsed.length] = { data: [ data[key], key ], value: data[key], result: data[key] };
        }
        return parsed;
      }
    }, %s))
    .result(function(event, data) { jQuery("#%s").val(data[1]); })
    .keyup(function() {
      if(this.value.length == 0) {
        \$('#%s').val('');
      }
    });
  });
</script>
EOF
, $this->generateId('autocomplete_' . $name), $this->getOption('url'), $this->getOption('config'), $this->generateId($name), $this->generateId($name));
    }
 /**
  * @param  string $name        The element name
  * @param  string $value       The value displayed in this widget
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  *
  * @see sfWidgetFormInput
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $input = parent::render($name, $value, $attributes, $errors);
     $suggestions = $this->renderTag('div', array('id' => 'geo_complete_suggestions', 'class' => 'auto_complete', 'style' => 'display:none'));
     $js = '<script type="text/javascript">location_input = "' . $this->generateId($name) . '"</script>';
     return $input . $suggestions . $js;
 }
 /**
  * @param  string $name        The element name
  * @param  string $value       The this widget is checked if value is not null
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  *
  * @see sfWidgetForm
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     if (!is_null($value)) {
         $attributes['checked'] = 'checked';
     }
     return parent::render($name, null, $attributes, $errors);
 }
 /**
  * @param  string $name        The element name
  * @param  string $value       The value displayed in this widget
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  *
  * @see sfWidgetForm
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     if ($this->getOption('int')) {
         if (!is_null($this->getOption('min'))) {
             $attributes['min'] = intval(ceil($this->getOption('min')));
         }
         if (!is_null($this->getOption('max'))) {
             $attributes['max'] = intval(floor($this->getOption('max')));
         }
         if (!is_null($value)) {
             $value = intval(round($value));
         }
         $attributes['step'] = isset($attributes['step']) ? intval(round($attributes['step'])) : 1;
     } else {
         if (!is_null($this->getOption('min'))) {
             $attributes['min'] = floatval($this->getOption('min'));
         }
         if (!is_null($this->getOption('max'))) {
             $attributes['max'] = floatval($this->getOption('max'));
         }
         if (!is_null($value)) {
             $value = floatval($value);
         }
     }
     return parent::render($name, $value, $attributes, $errors);
 }
 public function render($name, $value = array(), $attributes = array(), $errors = array())
 {
     $widget = array();
     use_javascript('jquery.tooltip/jquery.tooltip.js');
     use_stylesheet('../js/jquery.tooltip/jquery.tooltip.css');
     $widget['%thumbnails%'] = '';
     $widget['%thumbnails%'] .= '';
     $j = 0;
     foreach ($value as $j => $image) {
         if (!isset($image['id'])) {
             continue;
         }
         $fileIdInput = new sfWidgetFormInputHidden();
         $fileNameInput = new sfWidgetFormInputHidden();
         $commentInput = new sfWidgetFormInput(array(), array('maxlength' => 255));
         $largeInput = new sfWidgetFormInputHidden();
         $thumbnailInput = new sfWidgetFormInputHidden();
         $widget['%thumbnails%'] .= '<div class="upload_item" style="margin-bottom: 10px;" >' . '<span style="display: inline; width: 260px; float: left; text-align: center; padding-top: 10px;">' . link_to($image['name'], strval($image['Large']), array('class' => 'preview', 'rel' => strval($image['Thumbnail']))) . '</span>' . '&nbsp;' . $thumbnailInput->render($name . "[" . $j . "][Thumbnail]", strval($image['Thumbnail']), array()) . $largeInput->render($name . "[" . $j . "][Large]", strval($image['Large']), array()) . $fileNameInput->render($name . "[" . $j . "][name]", $image['name'], array()) . $fileIdInput->render($name . "[" . $j . "][id]", $image['id'], array()) . '<span>Title:</span>' . $commentInput->render($name . "[" . $j . "][description]", $image['description'], array('class' => 'text  input-mercha-account')) . '&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" class="del-photo"><img src="/images/cross.gif"  style="vertical-align:middle;" /></a>' . '</div>';
     }
     $i = $j + 1;
     $fileInput = new sfWidgetFormInputFile();
     $commentInput = new sfWidgetFormInput();
     $widget['%thumbnails%'] .= '<div class="upload_item" style="margin-bottom: 10px;" >' . $fileInput->render($name . "[" . $i . "][file]", null, array('class' => '', 'style' => "padding-left:0px;  width: 260px;  padding:0px; ")) . '&nbsp;' . '<span>Title:</span>' . $commentInput->render($name . "[" . $i . "][description]", null, array('class' => 'text  input-mercha-account')) . '&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" class="del-photo" style="vertical-align:middle;"><img src="/images/cross.gif" /></a>' . '</div>' . '<div class=" add-another-location bottom_add_new_category_link" style="padding-top: 0px; padding-bottom: 15px;">' . '<div class="plus_category">' . '<div class="left margin1"><img src="/images/plus.gif" /></div>' . '<div class="left margin_top3"><a href="#" class="add-photo">Add Another Photo</a></div>' . '</div>' . '</div>';
     $js = jq_javascript_tag("\r\n      jQuery(document).ready(function(){\r\n        i = jQuery('.upload_item').length + 1;\r\n        \r\n        jQuery('a.del-photo').live('click', function(e){\r\n          e.preventDefault();\r\n          jQuery(this).parents('.upload_item').remove();\r\n        });\r\n        \r\n        jQuery('.preview').tooltip({ \r\n            delay: 0, \r\n            showURL: false, \r\n            bodyHandler: function() { \r\n                return jQuery('<img/>').attr('src', jQuery(this).attr('rel')); \r\n            } \r\n        });\r\n        \r\n        jQuery('a.add-photo').live('click', function(e){\r\n          \r\n          e.preventDefault();\r\n          \r\n          var already = jQuery('.upload_item');\r\n          \r\n          var newUpload = '';\r\n          \r\n          var maxCount = " . intval($this->getOption('max_count')) . ";\r\n          \r\n          if ((maxCount > 0 && already.length < maxCount) || maxCount == 0) {\r\n          \r\n            newUpload = \r\n              '<div class=\\'upload_item\\' style=\\'margin-bottom: 10px;\\'><input type=\\'file\\' name=\\'" . $name . "[' + i + '][file]" . "\\' class=\"\" style=\"padding-left:0px;  width: 260px; padding:0px; \" />' +\n              '&nbsp;<span>Title:</span>' +\r\n              '<input type=\\'text\\' name=\\'" . $name . "[' + i + '][description]" . "\\' class=\\'text input-mercha-account\\' >';\r\n          \r\n            newUpload += \r\n              '&nbsp;&nbsp;&nbsp;&nbsp;<a href=\\'#\\' class=\\'del-photo\\'><img src=\\'/images/cross.gif\\'  style=\\'vertical-align:middle;\\' /></a>';\r\n          \r\n            \r\n            \r\n            newUpload += '</div>';\r\n            \r\n            jQuery(newUpload).insertBefore(jQuery(this).parents('div.add-another-location'));\r\n            i++;\r\n          }\r\n        })\r\n      \r\n      });\r\n    ");
     return $js . '<div id="uploader" style="width: 590px;">' . strtr($this->getOption('template'), $widget) . '</div>';
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $context = sfContext::getInstance();
     $response = $context->getResponse();
     $autocompleteDiv = "";
     // content_tag('div' , '', array('id' => $this->generateId($name) . '_autocomplete', 'class' => 'autocomplete'));
     $desc = '';
     if (true === $this->getOption('desc')) {
         $desc = '.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
                  return $( "<li>" )
                   .append( "<a>" + item.label + "<br>" + item.desc + "</a>" )
                   .appendTo( ul );
                }';
     }
     $autocompleteJs = $this->javascriptTag("\n              \n            \$(function(){\n               \n              \$('#" . $this->generateId($name) . "_ajaxtext').autocomplete({\n                  source: '" . url_for($this->getOption('url')) . "',\n                  delay:30,\n                  minChars:0,\n                  appendTo: '" . $this->getOption('appendTo') . "',\n                  max:30,\n                  width: 300,\n                  matchSubset:1,\n                  matchContains:1,\n                  cacheLength:10,\n                  autoFill:false,\n                  autoFocus: true,\n                  select: function( event, ui ) {\n                    \$('#" . $this->generateId($name) . "').val(ui.item.id);\n                    \$('#" . get_id_from_name($name) . "_ajaxcheckbox').prop('checked', true)\n                    \$('#" . get_id_from_name($name) . "_ajaxcheckboxText').html('" . __('kiválasztva') . "');\n                    \$('#" . $this->generateId($name) . "').trigger('change', [ui.item])\n                  }  \n                }){$desc}\n                \n              \n              \n              \$.fn.autocomplete.keypressEvent = function (evt, id){\n                 car =  evt.keyCode || evt.charCode;\n                 if (car != 27 && car!=9) //ESC + TAB\n                 {\n                    \$('#'+id).val('');\n                    \$('#'+id+'_ajaxcheckbox').attr('checked',false);\n                    \$('#'+id+'_ajaxcheckboxText').html('" . __('nincs kiválasztva') . "');                   \n                    \$('#" . $this->generateId($name) . "').trigger('change')\n                 } \n              }  \n                \n           });");
     $ihidden = new sfWidgetFormInputHidden();
     $ihiddenText = $ihidden->render($name, $value, $attributes);
     if ($value != '') {
         $checked = 'checked="checked"';
         $checkboxtext = "<span id='" . get_id_from_name($name) . "_ajaxcheckboxText'>" . __('kiválasztva') . "</span>";
     } else {
         $checked = '';
         $checkboxtext = "<span id='" . get_id_from_name($name) . "_ajaxcheckboxText'>" . __('nincs kiválasztva') . "</span>";
     }
     $checkbox = '<input type="checkbox" id="' . get_id_from_name($name) . '_ajaxcheckbox' . '" ' . $checked . ' disabled="disabled" />';
     $attributesText = array_merge($attributes, array('name' => false, 'id' => get_id_from_name($name) . '_ajaxtext'));
     $attributesText['onkeydown'] = "\$('#" . $this->generateId($name) . "_ajaxtext').autocomplete.keypressEvent(event, '" . $this->generateId($name) . "')";
     $itextText = parent::render($name, $this->getValueFromId($value), $attributesText, $errors);
     $indicator = '<span id="indicator-' . $this->generateId($name) . '" style="display: none;">&nbsp;&nbsp;<img src="/sfFormExtraPlugin/images/indicator.gif" alt="loading" /></span>';
     return $ihiddenText . $itextText . $checkbox . $checkboxtext . $indicator . $autocompleteDiv . $autocompleteJs;
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $response = sfContext::getInstance()->getResponse();
     $response->addJavascript('/sfExtraWidgetsPlugin/js/spinbutton.js');
     $response->addStylesheet('/sfExtraWidgetsPlugin/css/spinbutton.css');
     return parent::render($name, $value, $attributes, $errors) . javascript_tag("new SpinButton(\$('" . $this->generateId($name) . "'),{min:" . $this->getOption('min') . ", max:" . $this->getOption('max') . "}); \$('" . $this->generateId($name) . "').addClassName('spin-button');");
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     if (!isset($attributes['value']) && null !== $this->getOption('value_attribute_value')) {
         $attributes['value'] = $this->getOption('value_attribute_value');
     }
     return parent::render($name, null, $attributes, $errors);
 }
Пример #10
0
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $login = new sfWidgetFormInput();
     $login->setAttribute('readonly', 'readonly');
     $choices = array('0' => 'etu.utc.fr', '1' => 'utc.fr', '2' => 'escom.fr');
     $domaine = new sfWidgetFormChoice(array('choices' => $choices));
     return $login->render("nickname_email") . " @ " . $domaine->render($name);
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $response = sfContext::getInstance()->getResponse();
     $response->addStylesheet('/sfExtraWidgetsPlugin/css/autocompleter.css');
     $autocompleteDiv = content_tag('div', '', array('id' => $this->generateId($name) . '_autocomplete', 'class' => 'autocomplete'));
     $autocompleteJs = javascript_tag("\n            function ac_update_" . $this->generateId($name) . "(text, li)\n            {\n                \$('" . $this->generateId($name) . "').value = li.id;\n            }\n            \n            new Ajax.Autocompleter(\n                '" . $this->generateId($name) . "',\n                '" . $this->generateId($name) . '_autocomplete' . "',\n                '" . url_for($this->getOption('url')) . "',\n                {\n                    paramName: '" . $this->getOption('param') . "',\n                    indicator: 'indicator-" . $this->generateId($name) . "',\n                    minChars: " . $this->getOption('min_chars') . ",\n                    afterUpdateElement: ac_update_" . $this->generateId($name) . "\n                });");
     return parent::render($name, $value, $attributes, $errors) . '<span id="indicator-' . $this->generateId($name) . '" style="display: none;">&nbsp;&nbsp;<img src="/sfExtraWidgetsPlugin/img/ajax-loader.gif" align="absmiddle" alt="Loading" /></span>' . $autocompleteDiv . $autocompleteJs;
 }
 /**
  * Renders the widget.
  *
  * @param  string $name        The element name
  * @param  string $value       The value displayed in this widget
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  *
  * @see sfWidgetForm
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     if ($this->getOption('multiple')) {
         $name .= '[]';
         $attributes['multiple'] = $this->getOption('multiple');
     }
     return parent::render($name, $value, $attributes, $errors);
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $input = parent::render($name, null, $attributes, $errors);
     $root = sfContext::getInstance()->getRequest()->getRelativeUrlRoot();
     $captchaImage = $this->renderTag('img', array('src' => $root . '/captcha.php', 'alt' => 'captcha'));
     $result = $this->renderContentTag('p', $captchaImage) . $input;
     return $result;
 }
Пример #14
0
 public function sort_tasks_tree($title)
 {
     if ($this->access['edit']) {
         $f = new sfWidgetFormInput();
         $attributes = array('type' => 'button', 'class' => 'btn', 'onClick' => 'location.href=\'' . url_for($this->module . '/sortTree' . $this->add_url_params('?'), true) . '\'');
         return $f->render('', $title, $attributes);
     }
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $html = parent::render($name, $value, $attributes, $errors);
     $html .= "&nbsp;<span class='round_color'>&nbsp;</span>&nbsp;";
     $html .= image_tag('ColorPickerUIBtnWheel.png', array('class' => 'color_pckr'));
     $html .= "\n    <script type=\"text/javascript\">\n      \$(document).ready(function () { \n        \$('.round_color').css('backgroundColor','" . $value . "');      \n        \$('.color_pckr').qtip({\n          show: { delay: 0, event: 'click'},\n          hide: { event: 'click' },\n          style: {  \n            name: 'light',\n            title: { padding: '3px'},\n            width: { min: '215px', max: '215px'}\n          },         \n          content: {\n            title: { button: true, text: '&nbsp;' },\n            text: '<div id=\"colorpicker\"></div>',\n          },\n          events: {\n            show: function () {\n              \$('#colorpicker').farbtastic(function(color){\n                \$('#" . $this->generateId($name) . "').val(color);\n                \$('.round_color').css('backgroundColor', color);    \n              });\n            }\n          } \n       });       \n       \$('#" . $this->generateId($name) . "').keyup(function(){\n         \$.farbtastic('#colorpicker').setColor(\$(this).val());\n         \$('.round_color').css('backgroundColor', color);        \n       });\n       \$('#" . $this->generateId($name) . "').attr('value', '" . ($value ? $value : '#ededee') . "');\n     });\n   </script>\n    ";
     return $html;
 }
 /**
  * @param  string $name        The element name
  * @param  string $value       The value displayed in this widget
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  *
  * @see sfWidgetForm
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     if (!(strpos($this->getOption('mask'), 'decimal') === false)) {
         $value = sprintf("%01.2f", $value);
     }
     $attributes['class'] = isset($attributes['class']) ? $attributes['class'] . ' dc_widget_meio_masked' : 'dc_widget_meio_masked';
     $mask_name = $this->isCustomMask() ? 'custom_' . $this->generateId($name) . '_mask' : $this->getOption('mask');
     return $this->getCustomMaskJavascript($mask_name) . parent::render($name, $value, array_merge($attributes, array('alt' => $mask_name)), $errors);
 }
 /**
  * @param  string $name        The element name
  * @param  string $value       The value displayed in this widget
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  *
  * @see sfWidgetForm
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     if (!is_string($value) && !is_null($value)) {
         $numberFormat = new sfNumberFormat($this->getOption('culture'));
         $value = $numberFormat->format($value);
     }
     return parent::render($name, $value, $attributes, $errors);
     //return $this->renderTag('input', array_merge(array('type' => $this->getOption('type'), 'name' => $name, 'value' => $value), $attributes));
 }
Пример #18
0
    public function render($name, $value = null, $attributes = array(), $errors = array())
    {
        if (array_key_exists('class', $attributes)) {
            $attributes['class'] .= ' calendar';
        } else {
            $attributes['class'] = 'calendar';
        }
        if (!isset($attributes['id']) && isset($this->attributes['id'])) {
            $attributes['id'] = $this->attributes['id'];
        }
        $html = parent::render($name, $value, $attributes, $errors);
        $javaScript = sprintf(<<<EOF
 <script type="text/javascript">

    var datepickerDateFormat = '%s';
    var displayDateFormat = datepickerDateFormat.replace('yy', 'yyyy');

    \$(document).ready(function(){
        
        var dateFieldValue = \$.trim(\$("#%s").val());
        if (dateFieldValue == '') {
            \$("#%s").val(displayDateFormat);
        }

        daymarker.bindElement("#%s",
        {
            showOn: "both",
            dateFormat: datepickerDateFormat,
            buttonImage: "%s",
            buttonText:"",
            buttonImageOnly: true,
            changeMonth: true,
            changeYear: true,
            yearRange: "-100:+100",
            firstDay: 1,
            onClose: function() {
                \$("#%s").trigger('blur');
            }            
        });
        
        //\$("img.ui-datepicker-trigger").addClass("editable");
        
        \$("#%s").click(function(){
            daymarker.show("#%s");
            if (\$(this).val() == displayDateFormat) {
                \$(this).val('');
            }
        });
    
    });

</script>
EOF
, get_datepicker_date_format(sfContext::getInstance()->getUser()->getDateFormat()), $this->attributes['id'], $this->attributes['id'], $this->attributes['id'], theme_path('images/calendar.png'), $this->attributes['id'], $this->attributes['id'], $this->attributes['id']);
        return $html . $javaScript;
    }
 /**
  * @param  string $name        The element name
  * @param  string $value       The value displayed in this widget
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  *
  * @see sfWidgetForm
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     if ($this->getOption('multiple')) {
         $attributes['multiple'] = 'multiple';
         if (is_array($value)) {
             $value = implode(',', $value);
         }
     }
     return parent::render($name, $value, $attributes, $errors);
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $i18n = sfContext::getInstance()->getI18N();
     $widget = new sfWidgetFormInputFile(array(), $attributes);
     $file = '<dt>' . $i18n->__($this->getOption('file_label')) . '</dt>' . '<dd>' . $widget->render($name . '[file]', null, array('id' => $this->generateId($name))) . '</dd>';
     $widget = new sfWidgetFormInput(array(), $attributes);
     $description = '<dt>' . $i18n->__($this->getOption('description_label')) . '</dt>' . '<dd>' . $widget->render($name . '[description]') . '</dd>';
     $emptyValues = $this->getOption('empty_values');
     return '<dl>' . $file . $description . '</dl>';
 }
 /**
  * @param  string $name        The element name
  * @param  string $value       The this widget is checked if value is not null
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  *
  * @see sfWidgetForm
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     if (!is_null($value) && $value !== false) {
         $attributes['checked'] = 'checked';
     }
     if (!isset($attributes['value']) && !is_null($this->getOption('value_attribute_value'))) {
         $attributes['value'] = $this->getOption('value_attribute_value');
     }
     return parent::render($name, null, $attributes, $errors);
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $id = $this->generateId($name);
     if (isset($attributes['class'])) {
         $attributes['class'] .= ' w-theme-editor-color';
     } else {
         $attributes['class'] = ' w-theme-editor-color';
     }
     return content_tag('span', parent::render($name, $value, $attributes, $errors) . content_tag('span', image_tag('/sfPlopPlugin/vendor/famfamfam/silk/shading.png'), array('class' => 'w-clickable w-theme-editor-transparent', 'data-target' => $id)) . content_tag('span', image_tag('/sfPlopPlugin/vendor/famfamfam/silk/delete.png'), array('class' => 'w-clickable w-theme-editor-delete', 'data-target' => $id)));
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     if (isset($attributes['class'])) {
         $attributes['class'] .= ' w-autocomplete';
     } else {
         $attributes['class'] = 'w-autocomplete';
     }
     $attributes['data-autocomplete-url'] = url_for($this->getOption('url') . '?sf_culture=' . $this->getOption('culture')) . '?' . implode('&', $this->getOption('query_string'));
     return parent::render($name, $value, $attributes, $errors);
 }
    /**
     * @param  string $name        The element name
     * @param  string $value       The date displayed in this widget
     * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
     * @param  array  $errors      An array of errors for the field
     *
     * @return string An HTML tag string
     *
     * @see sfWidgetForm
     */
    public function render($name, $value = null, $attributes = array(), $errors = array())
    {
        if (isset($value['date'])) {
            $value = $value['date'];
        }
        $visibleValue = empty($value) ? '' : date('D, d-M-Y', strtotime($value));
        $fieldValue = empty($value) ? '' : date('Y/m/d', strtotime($value));
        $attributes['disabled'] = 1;
        $html = parent::render('datepicker_' . $name, $visibleValue, $attributes, $errors) . $this->renderTag('input', array('type' => 'hidden', 'name' => $name, 'value' => $fieldValue));
        //file_put_contents('log.txt', $html);
        $id = $this->generateId($name);
        $alt_id = $this->generateId('datepicker_' . $name);
        $culture = $this->getOption('culture');
        $cm = $this->getOption("change_month") ? "true" : "false";
        $cy = $this->getOption("change_year") ? "true" : "false";
        $nom = $this->getOption("number_of_months");
        $sbp = $this->getOption("show_button_panel") ? "true" : "false";
        if ($culture != 'en') {
            $html .= <<<EOHTML
<script type="text/javascript">
\t\$(function() {
    var params = \$.datepicker.regional['{$culture}'];
    params.changeMonth = {$cm};
    params.changeYear = {$cy};
    params.numberOfMonths = {$nom};
    params.showButtonPanel = {$sbp};
    params.buttonImage = '/images/calendar.gif';
    params.buttonImageOnly = true;
    \$("#{$id}").datepicker(params);
\t});
</script>
EOHTML;
        } else {
            $html .= <<<EOHTML
<script type="text/javascript">
\t\$(function() {
    var params = {
    onSelect: function(dateText, instance) {console.log(dateText); console.log(this.value); this.value = dateText;},
    altField: '#{$alt_id}',
    changeMonth : {$cm},
    changeYear : {$cy},
    numberOfMonths : {$nom},
\t\tshowOn: 'both',
    dateFormat: 'yy/m/d',
    altFormat: 'D, d-M-yy',
    buttonImage: '/images/calendar.gif',
    buttonImageOnly: true,
    showButtonPanel : {$sbp} };
    \$("#{$id}").datepicker(params);
\t});
</script>
EOHTML;
        }
        return $html;
    }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     if (array_key_exists('class', $attributes)) {
         $attributes['class'] .= ' ohrm_datepicker';
     } else {
         $attributes['class'] = 'ohrm_datepicker';
     }
     $html = parent::render($name, $value, $attributes, $errors);
     $html .= $this->renderTag('input', array('type' => 'button', 'id' => "{$this->attributes['id']}_Button", 'class' => 'calendarBtn', 'style' => 'float: none; display: inline; margin-left: 16px;', 'value' => ''));
     return $html;
 }
 /**
  * Render the current widget
  *
  * @param  string $name        The element name
  * @param  string $value       The this widget is checked if value is not null
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  *
  * @see sfWidgetForm
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $attributes = array_merge($this->attributes, $attributes);
     $this->attributes = array();
     $tag = parent::render($name, $value, array(), $errors);
     $style = 'border: 0;';
     if (isset($attributes['style'])) {
         $style .= ' ' . $attributes['style'];
         unset($attributes['style']);
     }
     return $tag . $this->renderTag('input', array_merge(array('type' => 'text', 'value' => $this->getOption('text', $value), 'readonly' => 'readonly', 'style' => $style), $attributes));
 }
Пример #27
0
    /**
     * @param  string $name        The element name
     * @param  string $value       The date displayed in this widget
     * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
     * @param  array  $errors      An array of errors for the field
     *
     * @return string An HTML tag string
     *
     * @see sfWidgetForm
     */
    public function render($name, $value = null, $attributes = array(), $errors = array())
    {
        $attributes = $this->getAttributes();
        $input = new sfWidgetFormInput(array(), $attributes);
        $date = new DateTime($value);
        $html = $input->render($name, $date->format('m/d/Y'));
        $id = $input->generateId($name);
        $culture = $this->getOption('culture');
        $cm = $this->getOption("change_month") ? "true" : "false";
        $cy = $this->getOption("change_year") ? "true" : "false";
        $nom = $this->getOption("number_of_months");
        $sbp = $this->getOption("show_button_panel") ? "true" : "false";
        $showOn = $this->getOption("show_on");
        $buttonImage = $this->getOption("button_image");
        $bio = $this->getOption("button_image_only") ? "true" : "false";
        if ($culture != 'en') {
            $html .= <<<EOHTML
<script type="text/javascript">
\t\$(function() {
    var params = \$.datepicker.regional['{$culture}'];
    params.dateFormat = 'mm/dd/yy';
    params.changeMonth = {$cm};
    params.changeYear = {$cy};
    params.numberOfMonths = {$nom};
    params.showButtonPanel = {$sbp};
    params.showOn = '{$showOn}';
    params.buttonImage = '{$buttonImage}';
\t\tparams.buttonImageOnly = {$bio};
    \$("#{$id}").datepicker(params);
\t});
</script>
EOHTML;
        } else {
            $html .= <<<EOHTML
<script type="text/javascript">
\t\$(function() {
    var params = {
      dateFormat: 'mm/dd/yy',
      changeMonth : {$cm},
      changeYear : {$cy},
      numberOfMonths : {$nom},
      showButtonPanel : {$sbp},
      showOn : '{$showOn}',
      buttonImage: '{$buttonImage}',
      buttonImageOnly: {$bio}
    };
    \$("#{$id}").datepicker(params);
\t});
</script>
EOHTML;
        }
        return $html;
    }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $response = sfContext::getInstance()->getResponse();
     $response->addJavascript('/sfExtraWidgetsPlugin/js/money.js');
     $response->addStylesheet('/sfExtraWidgetsPlugin/css/money.css');
     if (is_null($value)) {
         $value = 0;
     }
     $numberFormat = new sfNumberFormat(sfContext::getInstance()->getUser()->getCulture());
     $value = $numberFormat->format($value, '#.00');
     return '<div id="container-' . $this->generateId($name) . '">' . parent::render($name, $value, $attributes, $errors) . '</div>' . javascript_tag("new Money(\$('" . $this->generateId($name) . "'),{ symbol: '" . $this->getOption('symbol') . "'})");
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $response = sfContext::getInstance()->getResponse();
     $response->addJavascript('/sfExtraWidgetsPlugin/js/datepicker.js');
     $response->addStylesheet('/sfExtraWidgetsPlugin/css/datepicker_' . $this->getOption('style') . '.css');
     $picker = '&nbsp;<img src="/sfExtraWidgetsPlugin/img/datepicker/datepicker_icon.png" align="absmiddle" id="' . $this->generateId($name) . '_icon" alt="" style="cursor:pointer;" onclick="dp_display(\'' . $this->generateId($name) . '\')" />';
     if (!is_null($value) && $value != '') {
         if (strtotime($value) != '') {
             $value = format_date(date('Y-m-d', strtotime($value)), sfConfig::get('app_datepicker_output_sf_format'));
         }
     }
     return parent::render($name, $value, $attributes, $errors) . $picker;
 }
 /**
  * Render field
  * 
  * @param   string  $name       Element name
  * @param   string  $value      Element value
  * @param   array   $attributes HTML attributes [optional]
  * @param   array   $errors     Errors for the field [optional]
  * @return  string  XHTML compliant tag
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $s[] = '<script type="text/javascript">';
     $s[] = 'jQuery(document).ready(function(){';
     $s[] = "jQuery('#" . $this->generateId('autocomplete_' . $name) . "')";
     $s[] = ".autocomplete('" . $this->getOption('url') . "',jQuery.extend({},{";
     $s[] = "dataType:'json',scroll:true,resultsClass:'ui-autocomplete-menu ui-menu ui-widget ui-widget-content ui-corner-all',loadingClass:'acpl_loading',";
     $s[] = "inputClass:'acpl_input',parse:function(data){var parsed=[];for(key in data){";
     $s[] = "parsed[parsed.length]={data:[data[key].value,key],value:data[key].value,result:data[key].result};";
     $s[] = "}return parsed;}}, " . $this->getOption('config') . ")).result(function(event,data){";
     $s[] = "jQuery('#" . $this->generateId($name) . "').val(data[1]);});});";
     $s[] = '</script>';
     return $this->renderTag('input', array('type' => 'hidden', 'name' => $name, 'value' => $value, 'class' => '')) . parent::render('autocomplete_' . $name, $this->getVisibleValue($value), $attributes, $errors) . implode($s);
 }