/** * @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; }
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>' . ' ' . $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')) . ' <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; ")) . ' ' . '<span>Title:</span>' . $commentInput->render($name . "[" . $i . "][description]", null, array('class' => 'text input-mercha-account')) . ' <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 ' <span>Title:</span>' +\r\n '<input type=\\'text\\' name=\\'" . $name . "[' + i + '][description]" . "\\' class=\\'text input-mercha-account\\' >';\r\n \r\n newUpload += \r\n ' <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 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()) { $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()) { $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 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; }
/** * @param string $name The element name * @param string $value The date and time 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 */ function render($name, $value = null, $attributes = array(), $errors = array()) { $options = $this->getOptions(); $date_format = $options['format_date']; $value = (string) $value == (string) (int) $value ? (int) $value : strtotime($value); if ($value === false) { $value = array('date1' => null, 'date2' => null); } else { $value = array('date1' => 'new Date(' . date('Y', $value) . ', ' . (date('n', $value) - 1) . ', ' . date('j', $value) . ')', 'date2' => date($date_format['php'], $value)); } $add = ''; if ($value['date1']) { $add .= ', defaultDate:' . $value['date1']; } if ($options['change_year']) { $add .= ', changeYear: true'; } if ($options['change_month']) { $add .= ', changeMonth: true'; } if ($options['button']) { $add .= ", showOn: 'both', buttonImage: '" . $options['button'] . "', buttonImageOnly: true"; } if ($options['min_date']) { $add .= ", minDate: '" . $options['min_date'] . "'"; } if ($options['max_date']) { $add .= ", maxDate: '" . $options['max_date'] . "'"; } unset($options['format_date'], $options['change_month'], $options['change_year'], $options['min_date'], $options['max_date'], $options['button']); $input_widget = new sfWidgetFormInput($options, $this->getAttributes()); if (isset($attributes['id'])) { $id = $attributes['id']; } else { $id = $this->generateId($name); } $date = $input_widget->render($name, $value['date2'], $attributes) . sprintf(<<<EOF <script type="text/javascript"> //<![CDATA[ jQuery(function() { jQuery("#%s").datepicker({ dateFormat: '%s'%s }); }); //]]> </script> EOF , $id, $date_format['js'], $add); return $date; }
/** * @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 = 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); }
/** * @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; }
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;"> <img src="/sfFormExtraPlugin/images/indicator.gif" alt="loading" /></span>'; return $ihiddenText . $itextText . $checkbox . $checkboxtext . $indicator . $autocompleteDiv . $autocompleteJs; }
/** * Configures the current widget. * * @param array $options An array of options * @param array $attributes An array of default HTML attributes * * @see sfWidgetFormInput */ protected function configure($options = array(), $attributes = array()) { parent::configure($options, $attributes); $this->setOption('type', 'file'); $this->setOption('needs_multipart', true); }
/** * Configures the current widget. * * @param array $options An array of options * @param array $attributes An array of default HTML attributes * * @see sfWidgetFormInput */ protected function configure($options = array(), $attributes = array()) { parent::configure($options, $attributes); $this->setOption('is_hidden', true); $this->setOption('type', 'hidden'); }
/** * @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)); }
public function render($name, $value = null, $attributes = array(), $errors = array()) { $html = parent::render($name, $value, $attributes, $errors); $html .= " <span class='round_color'> </span> "; $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: ' ' },\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; }
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; }
/** * Configures the current widget. * * @param array $options An array of options * @param array $attributes An array of default HTML attributes * * @see sfWidgetForm */ protected function configure($options = array(), $attributes = array()) { if (array_key_exists('size', $options)) { $this->attributes['size'] = $options['size']; } parent::configure($options, $attributes); $this->setOption('type', 'text'); }
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;"> <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 configure($options = array(), $attributes = array()) { sfContext::getInstance()->getConfiguration()->loadHelpers(array('Asset', 'I18N')); parent::configure($options, $attributes); $this->addOption('locale', 'es'); $this->addOption('config', '{}'); $this->addOption('use_own_help', true); $this->addOption('own_help', __('Date format is "dd/mm/yyyy"')); }
/** * @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)); }
public function configure($options = array(), $attributes = array()) { $this->addRequiredOption('url'); $this->addOption('param', 'autocomplete'); $this->addOption('min_chars', 2); $this->addOption('obj', null); $this->addOption('print', ''); parent::configure($options, $attributes); }
/** * @param array $options An array of options * @param array $attributes An array of default HTML attributes * * @see sfWidgetFormInput */ protected function configure($options = array(), $attributes = array()) { $this->addOption('display_value', "<strong>%value%</strong>"); $this->addOption('null_value', "<strong>N/A</strong>"); $this->addOption('model'); $this->addOption('input_hidden', true); parent::configure($options, $attributes); // $this->setOption('read_only', true); }
public function render($name, $value = array(), $attributes = array(), $errors = array()) { $choices = $this->widget->getChoices(); $multiple = $this->widget->getOption('multiple'); $html = ''; $type = $multiple ? 'checkbox' : 'radio'; $value = is_array($value) ? $value : array($value); foreach ($choices as $index => $label) { $widget = new sfWidgetFormInput(array('type' => $type), array('value' => $index)); $widget->setParent($this->widget->getParent()); $attributes = array(); if (in_array($index, $value)) { $attributes['checked'] = "checked"; } $html .= sprintf('<label class="checkbox inline">%s %s</label>', $widget->render($name, $index, $attributes), $label); } 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()) { $attributes = $this->getAttributes(); // Set date to requested format if ($this->getOption('date_format') && $value) { $value = date($this->getOption('date_format'), strtotime($value)); } $input = new sfWidgetFormInput(array(), $attributes); $html = $input->render($name, $value); $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"; 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}; \$("#{$id}").datepicker(params); \t}); </script> EOHTML; } else { $html .= <<<EOHTML <script type="text/javascript"> \t\$(function() { var params = { changeMonth : {$cm}, changeYear : {$cy}, numberOfMonths : {$nom}, 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'] .= ' 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 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); }
/** * @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); }