/**
     * Renders the widget.
     *
     * @param  string $name        The element name
     * @param  string $value       The value selected 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_null($value)) {
            $value = array();
        }
        $choices = $this->getOption('choices');
        if ($choices instanceof sfCallable) {
            $choices = $choices->call();
        }
        $associated = array();
        $unassociated = array();
        foreach ($choices as $key => $option) {
            if (in_array(strval($key), $value)) {
                $associated[$key] = $option;
            } else {
                $unassociated[$key] = $option;
            }
        }
        $associatedWidget = new sfWidgetFormChoice(array_merge($this->getOption('list_options'), array('choices' => $associated, 'multiple' => true, 'expanded' => true)));
        return strtr($this->getOption('template'), array('%class%' => 'USJjQueryUIAutocomplete', '%id%' => $this->generateId($name), '%list%' => $associatedWidget->render($name, $value), '%autocomplete%' => $this->renderTag('input', array('type' => 'text', 'name' => 'autocomplete_' . $name)) . sprintf(<<<EOF
\t<script type="text/javascript">
\t  jQuery(document).ready(function() {

  \t    jQuery('#%s').focus(function(){ \$(this).val(''); }).trigger('focus');
\t    jQuery('#%s').blur(function(){ \$(this).val('%s'); }).trigger('blur');

\t    if (!\$('div#%s_list ul.checkbox_list').length) {
\t      \$('div#%s_list').append('<ul class="checkbox_list"></ul>');
\t    }

\t    jQuery('#%s').autocomplete({
\t     source: %s,
\t     select: function(event, ui) {
\t       if (!\$('#%s_'+ui.item.id).length) {
                 var ul = \$('div#%s_list ul.checkbox_list');
\t\t \$('<li><input type="checkbox" checked="checked" id="%s_'+ui.item.id+'" value="'+ui.item.id+'" name="%s"> <label for="%s_'+ui.item.id+'">'+ui.item.value+'</label></li>').prependTo(ul);
\t       }
\t       \$(this).trigger('blur');
\t    }
\t});

\tjQuery('div#%s_list').change(function(e){
\t  var elt = \$(e.target);
\t  if (\$(elt).is(':not(:checked)')) {
\t    \$(elt).parent('li').animate({'backgroundColor':'#fb6c6c'},300);
\t  }
\t  setTimeout(function(){
           if (\$(elt).is(':not(:checked)')) {
\t     \$(elt).parent('li').slideUp(300,function() { \$(this).remove() });
\t   } else {
\t     \$(elt).parent('li').css({'backgroundColor':'#fff'});
\t   }
\t },3000);
\t});
      });
</script>
EOF
, $this->generateId('autocomplete_' . $name), $this->generateId('autocomplete_' . $name), $this->getOption('help'), $this->generateId($name), $this->generateId($name), $this->generateId('autocomplete_' . $name), '"' . $this->getOption('source') . '"', $this->generateId($name), $this->generateId($name), $this->generateId($name), $name, $this->generateId($name), $this->generateId($name))));
    }
示例#2
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 configure($options = array(), $attributes = array())
 {
     $this->addOption('add_empty', false);
     $this->addOption('order', null);
     parent::configure($options, $attributes);
     $this->setOption('choices', array());
 }
    /**
     * @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())
    {
        $id = $this->generateId($name);

        $return = parent::render($name, $value, $attributes, $errors);

        $return .= sprintf(<<<EOF
<script type="text/javascript">
function formatResult(item)
{
    return item.text;
}

jQuery("#%s").select2(
{
    width:              '%s',
    allowClear:         %s
});
</script>
EOF
            ,
            $id,
            $this->getOption('width'),
            $this->getOption('add_empty') == true ? 'true' : 'false'
        );

        return $return;
    }
 /**
  * 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())
 {
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('I18N'));
     $default_text = $this->getOption('default_text', null);
     if ($default_text) {
         $default_text = __($default_text);
     } else {
         $default_text = $this->getOption('multiple') ? __("Select Some Options") . '...' : __("Select an Option") . '...';
     }
     $align_right = $this->getOption('align_right', null);
     if ($align_right) {
         if (!isset($attributes['class'])) {
             $attributes['class'] = '';
         }
         $attributes['class'] .= ' chzn-select chzn-rtl';
     }
     if (!isset($attributes['style'])) {
         $attributes['style'] = 'min-width: 300px; max-width: 700px;';
     } else {
         $attributes['style'] = '; min-width: 300px; max-width: 700px;';
     }
     $html = parent::render($name, $value, $attributes, $errors);
     $html .= dcWidgetFormChosenChoice::getWidgetInitializationJS($this->generateId($name), $value, $default_text);
     return $html;
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     if (!$value) {
         $value = $this->getAttribute('value');
     }
     return parent::render($name, $value, $attributes, $errors);
 }
 public function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
     $this->addOption('multiple', true);
     $this->addOption('extended', true);
     $this->addOption('is_choose', false);
 }
 protected function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
     if (!isset($options['renderer_class'])) {
         $this->setOption('renderer_class', 'WidgetFormSelectBootstrapRadio');
     }
 }
 protected function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
     $this->addRequiredOption('petition_id');
     $this->addRequiredOption('petition_text_id');
     $this->addOption('choices');
     $this->addOption('renderer_class', 'sfWidgetFormSelectPetitionTextHash');
 }
 public function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
     $this->addOption('multiple', true);
     $this->addOption('extended', true);
     $this->addRequiredOption('user_ref');
     $this->addRequiredOption('collection_ref');
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     if (false !== $this->getOption('add_empty')) {
         $choices[''] = true === $this->getOption('add_empty') ? '' : $this->translate($this->getOption('add_empty'));
         $this->setOption('choices', array_merge($choices, $this->getOption('choices')));
     }
     return parent::render($name, $value, $attributes, $errors);
 }
示例#12
0
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $field = parent::render($name, $value, $attributes, $errors);
     $name = " " . $this->getOption('name') . " ";
     $module = $this->getOption('module');
     $link = '<a href="' . sfContext::getInstance()->getController()->genUrl("{$module}/deleteInstitucion") . '?idm=' . $this->getOption('parent_id') . '&idi=' . $this->getOption('model_id') . '" onclick="if (confirm(\'sure?\')) { return true; };return false;"><img src="/sfPropelPlugin/images/delete.png" alt="borrar" /></a>';
     return (!$this->getOption('name') ? $field : '') . $name . ($this->getOption('name') ? $link : '');
 }
 /**
  * Constructor.
  *
  * Available options:
  *
  *  * culture:   The culture to use for internationalized strings
  *  * languages: An array of language codes to use
  *  * add_empty: Whether to add a first empty value or not (false by default)
  *               If the option is not a Boolean, the value will be used as the text value
  *
  * @param array $options     An array of options
  * @param array $attributes  An array of default HTML attributes
  *
  * @see sfWidgetFormChoice
  */
 public function configure($options = array(), $attributes = array())
 {
     $this->addOption('culture');
     $this->addOption('languages');
     $this->addOption('add_empty', false);
     parent::configure($options, $attributes);
     $this->setOption('choices', array());
 }
 /**
  * Options:
  *
  *   * model:        the model (required)
  *   * add_empty:    if add an empty option (false by default)
  *   * method:       the method to show the document (__toString by default)
  *   * find_options: the options for the find (empty array by default)
  *
  * @see sfWidgetFormSelect
  */
 protected function configure($options = array(), $attributes = array())
 {
     $this->addRequiredOption('model');
     $this->addOption('add_empty', false);
     $this->addOption('method', '__toString');
     $this->addOption('find_options', array());
     parent::configure($options, $attributes);
 }
 /**
  * Constructor.
  *
  * Available options:
  *
  *  * model:                The model class (required)
  *  * table_method:         A method to return a formatted array of key => value (required)
  *  * table_method_params:  An array of parameters to pass to the table_method
  *  * add_empty:            Whether to add a first empty value or not (false by default)
  *                          If the option is not a Boolean, the value will be used as the text value
  *  * multiple:             true if the select tag must allow multiple selections (false by default)
  *
  * @see sfWidgetFormChoice
  */
 protected function configure($options = array(), $attributes = array())
 {
     $this->addRequiredOption('model');
     $this->addRequiredOption('table_method');
     $this->addOption('table_method_params', null);
     $this->addOption('add_empty', false);
     $this->addOption('multiple', false);
     parent::configure($options, $attributes);
 }
 public function __construct($options = array(), $attributes = array())
 {
     if (isset($options['choices'])) {
         $options['choices'] = array_merge($options['choices'], dmContext::getInstance()->getServiceContainer()->getService('i18n')->translateArray(dmWidgetFormChoiceEasing::$easing));
     } else {
         $options['choices'] = dmContext::getInstance()->getServiceContainer()->getService('i18n')->translateArray(dmWidgetFormChoiceEasing::$easing);
     }
     parent::__construct($options, $attributes);
 }
示例#17
0
 /**
  * 
  * Constructor.
  * Available options:
  * * choices:          An array of possible choices (required)
  * multiple:         true if the select tag must allow multiple selections
  * expanded:         true to display an expanded widget
  * if expanded is false, then the widget will be a select
  * if expanded is true and multiple is false, then the widget will be a list of radio
  * if expanded is true and multiple is true, then the widget will be a list of checkbox
  * renderer_class:   The class to use instead of the default ones
  * renderer_options: The options to pass to the renderer constructor
  * renderer:         A renderer widget (overrides the expanded and renderer_options options)
  * The choices option must be: new sfCallable($thisWidgetInstance, 'getChoices')
  * @param array $options     An array of options
  * @param array $attributes  An array of default HTML attributes
  * @see sfWidgetFormChoiceBase
  */
 protected function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
     $this->addOption('multiple', false);
     $this->addOption('expanded', false);
     $this->addOption('renderer_class', false);
     $this->addOption('renderer_options', array());
     $this->addOption('renderer', false);
 }
 /**
  * Constructor.
  *
  * Available options:
  *
  *  * root_id:      The root_id (required)
  *  * add_empty:    Whether to add a first empty value or not (false by default)
  *                  If the option is not a Boolean, the value will be used as the text value
  *  * method:       The method to use to display object values (__toString by default)
  *  * key_method:   The method to use to display the object keys (getPrimaryKey by default)
  *  * 
  *  * query:        Custom query
  *
  * @see sfWidgetFormSelect
  */
 protected function configure($options = array(), $attributes = array())
 {
     $this->addRequiredOption('root_id');
     $this->addOption('add_empty', false);
     $this->addOption('method', '__toString');
     $this->addOption('key_method', 'getPrimaryKey');
     $this->addOption('multiple', false);
     $this->addOption('query', false);
     parent::configure($options, $attributes);
 }
 public function getChoices()
 {
     $filters = sfPlopSlotPeer::retrieveAllByTemplate('GoogleMapsFilter', $this->getOption('page_id'), $this->getOption('page_culture'));
     $options_for_filter = array('' => '');
     foreach ($filters as $filter_object) {
         $options_for_filter[$filter_object->getValue()] = $filter_object->getValue();
     }
     $this->setOption('choices', $options_for_filter);
     return parent::getChoices();
 }
 public function __construct($options = array(), $attributes = array())
 {
     $this->addOption('empty_value', '&nbsp;');
     $this->addOption('collapse', false);
     $this->addOption('restrict_size', false);
     $this->addOption('restricted_size', 125);
     $this->addOption('add_hidden_input', true);
     parent::__construct($options, $attributes);
     $this->setOption('multiple', true);
 }
 /**
  * Constructor.
  *
  * Available options:
  *
  *  * model:           The model class (required)
  *  * add_empty:       Whether to add a first empty value or not (false by default)
  *                     If the option is not a Boolean, the value will be used as the text value
  *  * method:          The method to use to display object values (__toString by default)
  *  * key_method:      The method to use to display the object keys (getPrimaryKey by default)
  *  * base_query:      The base_query for nested set
  *  * multiple:        true if the select tag must allow multiple selections
  *  * level_character: The character used to represent a level (- by default)
  *
  * @see sfWidgetFormSelect
  */
 protected function configure($options = array(), $attributes = array())
 {
     $this->addRequiredOption('model');
     $this->addOption('add_empty', false);
     $this->addOption('method', '__toString');
     $this->addOption('key_method', 'getPrimaryKey');
     $this->addOption('base_query', null);
     $this->addOption('multiple', false);
     $this->addOption('level_character', '&nbsp;&nbsp;');
     parent::configure($options, $attributes);
 }
 /**
  * Constructor.
  *
  * Available options:
  *
  *  * model:      The model class (required)
  *  * add_empty:  Whether to add a first empty value or not (false by default)
  *                If the option is not a Boolean, the value will be used as the text value
  *  * method:     The method to use to display object values (__toString by default)
  *  * order_by:   An array composed of two fields:
  *                  * The column to order by the results (must be in the PhpName format)
  *                  * asc or desc
  *  * query:   A query to use when retrieving objects
  *  * connection: The Doctrine connection to use (null by default)
  *  * multiple:   true if the select tag must allow multiple selections
  *
  * @see sfWidgetFormSelect
  */
 protected function configure($options = array(), $attributes = array())
 {
     $this->addRequiredOption('model');
     $this->addOption('add_empty', false);
     $this->addOption('method', '__toString');
     $this->addOption('order_by', null);
     $this->addOption('query', null);
     $this->addOption('connection', null);
     $this->addOption('multiple', false);
     parent::configure($options, $attributes);
 }
  public function render($name, $value = null, $attributes = array(), $errors = array())
  {
    $current_catalogue = strval($this->parent->getFormFormatter()->getTranslationCatalogue());

    $this->parent->getFormFormatter()->setTranslationCatalogue($this->getOption('catalogue'));

    $response = parent::render($name, $value, $attributes, $errors);

    $this->parent->getFormFormatter()->setTranslationCatalogue($current_catalogue);

    return $response;
  }
 /**
  * Constructor.
  *
  * Available options:
  *
  *  * model:       The model class (required)
  *  * add_empty:   Whether to add a first empty value or not (false by default)
  *                 If the option is not a Boolean, the value will be used as the text value
  *  * method:      The method to use to display object values (__toString by default)
  *  * key_method:  The method to use to display the object keys (getPrimaryKey by default) 
  *  * order_by:    An array composed of two fields:
  *                   * The column to order by the results (must be in the PhpName format)
  *                   * asc or desc
  *  * criteria:    A criteria to use when retrieving objects
  *  * connection:  The Propel connection to use (null by default)
  *  * multiple:    true if the select tag must allow multiple selections
  *  * peer_method: The peer method to use to fetch objects
  *
  * @see sfWidgetFormSelect
  */
 protected function configure($options = array(), $attributes = array())
 {
     $this->addRequiredOption('model');
     $this->addOption('add_empty', false);
     $this->addOption('method', '__toString');
     $this->addOption('key_method', 'getPrimaryKey');
     $this->addOption('order_by', null);
     $this->addOption('criteria', null);
     $this->addOption('connection', null);
     $this->addOption('multiple', false);
     $this->addOption('peer_method', 'doSelect');
     parent::configure($options, $attributes);
 }
 /**
  * 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
  * @author  relo_san
  * @since   february 8, 2010
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $s[] = '<script type="text/javascript">';
     $s[] = 'jQuery(document).ready(function(){';
     $s[] = '$(\'#' . $this->generateId($this->getOption('parent')) . '\').change(function(){';
     $s[] = 'var objectId=' . ($value ? $value : 'null') . ';$.getJSON(\'' . $this->getOption('url') . '\',';
     $s[] = '{id:$(\'#' . $this->generateId($this->getOption('parent')) . '\').val(),ajax:\'true\'},';
     $s[] = 'function(j){var options=\'\';for(var i=0;i<j.length;i++){';
     $s[] = 'options+=\'<option value="\'+j[i].id+\'"\'+(j[i].id==objectId?\' selected=[selected]\':\'\')+\'>\'+j[i].value+\'</option>\';';
     $s[] = '}$(\'select#' . $this->generateId($name) . '\').html(options);});});});';
     $s[] = '</script>';
     return parent::render($name, $value, $attributes, $errors) . implode($s);
 }
 /**
  * Constructor.
  *
  * Available options:
  *
  *  * culture:   The culture to use for internationalized strings
  *  * add_empty: Whether to add a first empty value or not (false by default)
  *               If the option is not a Boolean, the value will be used as the text value
  *
  * @param array $options     An array of options
  * @param array $attributes  An array of default HTML attributes
  *
  * @see sfWidgetFormChoice
  */
 protected function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
     $this->addOption('culture');
     $this->addOption('add_empty', false);
     $culture = isset($options['culture']) ? $options['culture'] : 'en';
     $timezones = array_keys(sfCultureInfo::getInstance($culture)->getTimeZones());
     $timezones = array_combine($timezones, $timezones);
     $addEmpty = isset($options['add_empty']) ? $options['add_empty'] : false;
     if (false !== $addEmpty) {
         $timezones = array_merge(array('' => true === $addEmpty ? '' : $addEmpty), $timezones);
     }
     $this->setOption('choices', $timezones);
 }
 public function __construct($options = array(), $attributes = array())
 {
     $choices = array();
     $modules = array();
     foreach (dmContext::getInstance()->getModuleManager()->getModules() as $module) {
         $actions = $module->getActions();
         foreach ($actions as $action) {
             $choiceName = $module->getName() . '|' . $action['name'];
             $choices[$module->getName() . '|' . $action['name']] = $module->getName() . ' | ' . $action['name'];
         }
     }
     $options['choices'] = $choices;
     parent::__construct($options, $attributes);
 }
 /**
  * Constructor.
  *
  * Available options:
  *
  *  * culture:   The culture to use for internationalized strings
  *  * countries: An array of country codes to use (ISO 3166)
  *  * add_empty: Whether to add a first empty value or not (false by default)
  *               If the option is not a Boolean, the value will be used as the text value
  *
  * @param array $options     An array of options
  * @param array $attributes  An array of default HTML attributes
  *
  * @see sfWidgetFormChoice
  */
 protected function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
     $this->addOption('culture');
     $this->addOption('countries');
     $this->addOption('add_empty', false);
     // populate choices with all countries
     $culture = isset($options['culture']) ? $options['culture'] : 'en';
     $countries = sfCultureInfo::getInstance($culture)->getCountries(isset($options['countries']) ? $options['countries'] : null);
     $addEmpty = isset($options['add_empty']) ? $options['add_empty'] : false;
     if (false !== $addEmpty) {
         $countries = array_merge(array('' => true === $addEmpty ? '' : $addEmpty), $countries);
     }
     $this->setOption('choices', $countries);
 }
 /**
  * Constructor.
  *
  * Available options:
  *
  *  * culture:   The culture to use for internationalized strings
  *  * languages: An array of language codes to use
  *  * add_empty: Whether to add a first empty value or not (false by default)
  *               If the option is not a Boolean, the value will be used as the text value
  *
  * @param array $options     An array of options
  * @param array $attributes  An array of default HTML attributes
  *
  * @see sfWidgetFormChoice
  */
 protected function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
     $this->addOption('culture');
     $this->addOption('languages');
     $this->addOption('add_empty', false);
     // populate choices with all languages
     $culture = isset($options['culture']) ? $options['culture'] : 'en';
     $kk_lang = isset($options['languages']) == true ? $options['languages'] : null;
     //var_dump(sfCultureInfo::getInstance($culture)->getLanguages());
     //exit;
     $languages = sfCultureInfo::getInstance($culture)->getLanguages();
     $addEmpty = isset($options['add_empty']) ? $options['add_empty'] : false;
     if (false !== $addEmpty) {
         $languages = array_merge(array('' => true === $addEmpty ? '' : $addEmpty), $languages);
     }
     $this->setOption('choices', $languages);
 }
    /**
     * @param  string $name        The element name
     * @param  string $value       The value selected 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())
    {
        $script = <<<EOS
\t<script>
\t\$(function() {
\t\tvar select = \$( "select[name='rt_comment[rating]']" ).hide();
\t\tvar slider = \$( "<div id='rating' style='display:inline-block; width:200px'></div>" ).insertAfter( select ).slider({
\t\t\tmin: 1,
\t\t\tmax: 11,
\t\t\trange: "min",
\t\t\tvalue: select[ 0 ].selectedIndex + 1,
\t\t\tslide: function( event, ui ) {
              \$("#ratingSelection").html((ui.value - 1) / 2);
              select[ 0 ].selectedIndex = ui.value - 1;
\t\t\t}
\t\t});
\t\tselect.change(function() {
          slider.slider( "value", this.selectedIndex + 1 );
\t\t});
\t});
\t</script>
EOS;
        return '0/5 ' . parent::render($name, $value, $attributes, $errors) . ' <span id="ratingSelection">5</span>/5' . $script;
    }