Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<select> input tag not working in Django #4904

Closed
Erwol opened this issue Jun 28, 2017 · 5 comments
Closed

<select> input tag not working in Django #4904

Erwol opened this issue Jun 28, 2017 · 5 comments

Comments

@Erwol
Copy link

Erwol commented Jun 28, 2017

Description

<select> tags are not working in Django because they need the class="browser-default" to appear in the browser.

Repro Steps

  1. Create a Form with multiple choices in Django
  2. Try to render it; you won't be able to see it

The solution is to overwrite the forms widget, but I think this should be fixed from materialize css project.

class JustAnotherForm(forms.ModelForm):
    multiplechoicefield= forms.CharField(
        max_length=124,
        widget=forms.Select(
            choices=ARTWORK_TYPES,
            attrs={'class': 'browser-default'}),
        
    )
@DanielRuf
Copy link
Contributor

Can you provide a codepen which reproduces it? Did you already inspect the element in the developer tools of the browser to find the problematic code?

@Dogfalo
Copy link
Owner

Dogfalo commented Jun 28, 2017

The select is meant to be initialized which you are not doing. In any case, we likely will make some changes to default elements in the upcoming releases

@Dogfalo Dogfalo closed this as completed Jun 28, 2017
@DanielRuf
Copy link
Contributor

Right, should be initalized with material_select() (I thought he did so in his project or component).

http://materializecss.com/forms.html

@Erwol
Copy link
Author

Erwol commented Jun 28, 2017

Hey @DanielRuf, I already found the problem when I post the issue. Sorry if it's not well explained. The thing is that Django renders select tags without any classes attached to the element, and as materialize css needs the browser-default set class in select tags, Django will render the template but you won't be able to see the select. The Django-side fix is to initialize the component as I posted up here. Maybe an easy fix'd be to allow native select tags. Thank you @Dogfalo.

@DanielRuf
Copy link
Contributor

as materialize css needs the browser-default set class in select tags

That is new to me. http://materializecss.com/forms.html#select

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants