Skip to content

Commit

Permalink
Uncrispify portadmin/SearchForm
Browse files Browse the repository at this point in the history
  • Loading branch information
stveit committed Oct 10, 2024
1 parent 4f86c9f commit 6a7754b
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions python/nav/web/portadmin/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
"""Forms for PortAdmin"""

from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms_foundation.layout import Layout, Row, Column, Submit
from nav.web.crispyforms import (
set_flat_form_attributes,
SubmitField,
FormRow,
FormColumn,
)


class SearchForm(forms.Form):
Expand All @@ -32,16 +36,19 @@ class SearchForm(forms.Form):

def __init__(self, *args, **kwargs):
super(SearchForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_action = 'portadmin-index'
self.helper.form_method = 'GET'
self.helper.layout = Layout(
Row(
Column('query', css_class='medium-9'),
Column(
Submit('submit', 'Search', css_class='postfix'),
css_class='medium-3',
),
css_class='collapse',
)
self.attrs = set_flat_form_attributes(
form_method='get',
form_action='portadmin-index',
form_fields=[
FormRow(
fields=[
FormColumn(fields=[self['query']], css_classes='medium-9'),
FormColumn(
fields=[SubmitField(value='Search', css_classes='postfix')],
css_classes='medium-3',
),
],
css_classes='collapse',
)
],
)

0 comments on commit 6a7754b

Please sign in to comment.