/**
  * 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, $this->getOption('config'));
     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())
    {
        $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;
    }
 protected function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
     $this->addRequiredOption("url");
     $this->addOption("new_label", "New");
     $this->addOption("ws_url", "@pm_widget_form_propel_choice_or_create");
 }
 public function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
     $this->setOption('model', 'sfGuardUserProfile');
     $this->setOption('method', 'getNameWithRole');
     $this->setOption('criteria', sfGuardUserProfileQuery::create()->filterByIsPublic(true));
     $this->setOption('multiple', true);
     $this->setOption('expanded', true);
 }
 /**
  * @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())
 {
     $select_tag = parent::render($name, $value, $attributes, $errors);
     $conten_tag = '<div class="select_with_add" id="' . $this->getAttribute('id') . '">';
     $conten_tag .= '<div class="win4add2select">';
     $conten_tag .= '<input link_to_add="' . url_for($this->getOption('action2Add')) . '" name="add2select" />';
     $conten_tag .= '<div class="btn-cover"><div class="icn icn-delete"></div></div>';
     $conten_tag .= '<div class="btn-cover"><div class="icn icn-submit"></div></div>';
     $conten_tag .= '</div>';
     $conten_tag .= $select_tag;
     $conten_tag .= '<div class="btn-cover"><div class="icn icn-add btn_add2Select4Win"></div>';
     $conten_tag .= '</div>';
     $conten_tag .= '</div>';
     return $conten_tag;
 }
 /**
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $select_tag = parent::render($name, $value, $attributes, $errors);
     $conten_tag = '<div class="moo_widget select_with_add" id="' . $this->getAttribute('id') . '">';
     $conten_tag .= '<div class="win_add2select">';
     $conten_tag .= '<input link_to_add="' . url_for($this->getOption('url')) . '" name="' . $this->getOption('input_name') . '" />';
     $conten_tag .= '<div class="icn icn_cancel"></div>';
     $conten_tag .= '<div class="icn icn_ok"></div>';
     $conten_tag .= '</div>';
     $conten_tag .= '<div class="error_response">';
     $conten_tag .= '</div>';
     $conten_tag .= $select_tag;
     $conten_tag .= '<div class="btn_add"><div class="icn icn_add"></div>';
     $conten_tag .= 'add';
     $conten_tag .= '</div>';
     $conten_tag .= '</div>';
     return $conten_tag;
 }
 public function getStylesheets()
 {
     return array_merge(parent::getStylesheets(), array('/dcReloadedFormExtraPlugin/css/token-input.css' => 'all', '/dcReloadedFormExtraPlugin/css/token-input-facebook.css' => 'all', '/dcReloadedFormExtraPlugin/css/token-input-mac.css' => 'all'));
 }
 /**
  * Available options:
  * 
  *  * group_by_method:  A method on the current model that will return the
  *                      object the widget is grouped by (i.e. getAuthor)
  * 
  * @see sfWidget
  */
 protected function configure($options = array(), $attributes = array())
 {
     $this->addRequiredOption('group_by_method');
     parent::configure($options, $attributes);
 }
 /**
  * Constructor.
  *
  * @see sfWidgetFormPropelChoice
  */
 protected function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
     $this->setOption('multiple', true);
 }