Monday, February 26, 2018

Trying to use tooltips in django 2.0 form

Hi there,

I have this in my forms.py:

class SubmissionForm(forms.Form):


    molecule_file = forms.FileField(validators=[FileExtensionValidator(settings.CONTENT_TYPES), file_size], help_text="Required: Select a PDB, MDL or MOL2 file")


But I am failing to make it work in my submit.html template. Currently, I am "hacking" with:

<p title="Required: Select a PDB, MDL or MOL2 file."><label>{{form.molecule_file.label}}</label>{{ form.molecule_file }}</p>


That will show the tooltip "Required: Sel..." if mouse pause over this field in the browser, but this is silly, I wish I could use something like:

<p title={{form.molecule_file.help_text}}><label>{{form.molecule_file.label}}</label>{{ form.molecule_file }}</p>


But that is not working, neither any combination I tried with .title etc.

Any suggestion would be very much appreciated.

Many thanks in advance,

Alan

-- 
I'll cycle across Britain in 2018 for a charity, would you consider
Many thanks!
--
Alan Wilter SOUSA da SILVA, DSc
Senior Bioinformatician, UniProt
European Bioinformatics Institute (EMBL-EBI)
European Molecular Biology Laboratory
Wellcome Trust Genome Campus
Hinxton
Cambridge CB10 1SD
United Kingdom
Tel: +44 (0)1223 494588

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEznbzmoK07JfXPp_MOvmYFe84a%3D5YiBQMEFJOtUsUzpjPjTGg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment