示例#1
0
    def generateComponentLabel(self):
        if self.label == None:
            return ''

        label = Element('label', {
            'id':self.id+'-label',
            'for':self.id,
            'class':self.labelClass
            })
            
        label.update(self.label)
        
        # Add the required star to the label
        if 'required' in self.validationOptions:
            labelRequiredStarSpan = Element('span',
                {'class':self.labelRequiredStarClass})
            labelRequiredStarSpan.update(self.requiredText)
            label.insert(labelRequiredStarSpan)

        return label
示例#2
0
    def generateComponentDiv(self, includeLabel=True):
        # Div tag contains everything about the component
        componentDiv = Element('div', {
            'id': self.id+'-wrapper',
            'class': 'jFormComponent '+self._class})

        # This causes issues with things that are dependent and should display by default
        # If the component has dependencies and the display type is hidden, hide by default
        # if(self.dependencyOptions !== None && isset(self.dependencyOptions['display']) && self.dependencyOptions['display'] == 'hide'):
        #    componentDiv.setAttribute('style', 'display: none')
        #

        # Style
        if self.style:
            componentDiv.addToAttribute('style', self.style)

        # Label tag
        if includeLabel:
            label = self.generateComponentLabel()
            componentDiv.insert(label)

        return componentDiv