Jeremy
Jeremy

Reputation: 1835

django-crispy-forms inline divs

I would like to get three inline div's using crispy forms (and I am SO close), but I am not sure exactly how. This is what I have so far:

self.helper.layout = Layout(
    Div(
        Div(
            'mothers_id','date','date_collector',
            css_class="form-inline", #this is the line I can't get just right (I think)
        ),
        Div(        
            'q_1a',
            'q_1b',
            'q_1c',
        ),
    )
)

Upvotes: 0

Views: 582

Answers (1)

madzohan
madzohan

Reputation: 11808

Example (coordinates):

    self.helper_coordinate = FormHelper()
    self.helper_coordinate.layout = Layout(
        Div(
            HTML(u'<div class="col-xs-2" style="line-height:35px;"><strong>Latitude:</strong></div>'),
            Div(AppendedText('lat_deg', '°'), css_class='col-xs-3'),
            Div(AppendedText('lat_min', '\''), css_class='col-xs-3'),
            Div(AppendedText('lat_sec', '"'), css_class='col-xs-4'),
            css_class='row-fluid'  # here you can add some custom class, for example 'row-fluid margin-top-15'
        ),
        Div(
            HTML(u'<div class="col-xs-2" style="line-height:35px;"><strong>Longitude:</strong></div>'),
            Div(AppendedText('lon_deg', '°'), css_class='col-xs-3'),
            Div(AppendedText('lon_min', '\''), css_class='col-xs-3'),
            Div(AppendedText('lon_sec', '"'), css_class='col-xs-4'),
            css_class='row-fluid'
        ),
    )

Upvotes: 1

Related Questions