Empty_Selector_widget_not_validated.patch

Davide Principi, 10/01/2014 09:01 AM

Download (3.34 KB)

View differences:

Nethgui/Js/jquery.nethgui.selector.js
17 17
            this._mode = (this.element.prop('tagName').toUpperCase() == 'SELECT') ? 'dropdown' : 'list';
18 18
            this._selection = [];
19 19
            this._multiple = this.element.hasClass('multiple');
20
            this._meta = this.element.children('input[type="hidden"]').first();           
20
            this._meta = this.element.children('input[type="hidden"]').first();
21
            this.element.on('nethguitooltip.' + this.namespace, $.proxy(this._createTooltip, this));
21 22
        },
22 23
        _setOption: function( key, value ) {
23 24
            SUPER.prototype._setOption.apply( this, arguments );
......
152 153
                }
153 154

  
154 155
            });
156
        },
157
        _createTooltip: function(e, options) {
158
            if( ! this.element.Tooltip) {
159
                $.debug('Tooltip type was not found. Maybe jquery.nethgui.tooltip.js is missing?');
160
            }
161

  
162
            // Move tooltip on the right edge for right-labeled input controls:
163
            if( ! options.target && this.element.get(0).tagName.toLowerCase() === 'select'
164
                && this.element.parent().hasClass('label-right')) {
165
                options.target = this.element.siblings('label[for=' + this.element.attr('id') + ']').first();
166
            }
167

  
168
            this.element.Tooltip(options);
155 169
        }
156 170
    });
157 171
}( jQuery ));
Nethgui/System/Validator.php
92 92
            $set = $args;
93 93
        }
94 94

  
95
        if (count($set) > 5) {
95
        if(count($set) === 0) {
96
            $setToShow = FALSE;
97
        } elseif (count($set) > 5) {
96 98
            $setToShow = array_slice($set, 0, 3);
97 99
            $setToShow[] = '... ';
98 100
            $setToShow = array_merge($setToShow, array_slice($set, -2, 2));
......
100 102
            $setToShow = $set;
101 103
        }
102 104

  
103
        $messageTemplate = array('valid_memberOf', array(implode(', ', $setToShow)));
105
        $messageTemplate = is_array($setToShow) ? array('valid_memberOf', array(implode(', ', $setToShow))) : array('valid_emptySet', array());
104 106

  
105 107
        return $this->addToChain(__FUNCTION__, $messageTemplate, $set);
106 108
    }
Nethgui/Widget/Xhtml/Selector.php
77 77
        } else {
78 78
            $tagContent = $this->optGroups($value, $choices);
79 79
        }
80
        $content = $this->labeledControlTag($label, 'select', $name, $flags, '', $attributes, $tagContent);
81
        return $content;
80
        $hiddenInput = $this->controlTag('input', $name, 0, '', array('value' => '', 'type' => 'hidden', 'id' => FALSE));
81
        return $hiddenInput . $this->labeledControlTag($label, 'select', $name, $flags, '', $attributes, $tagContent);
82 82
    }
83 83

  
84 84
    private function renderWidgetList($value, $choices, $attributes)