Created
May 30, 2012 16:59
-
-
Save moschlar/2837623 to your computer and use it in GitHub Desktop.
A ToscaWidgets2 widget that needs a dynamic SelectField and does work :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
''' | |
Created on 17.03.2012 | |
@author: moschlar | |
''' | |
import tw2.core as twc | |
import tw2.forms as twf | |
import tw2.bootstrap as twb | |
try: | |
from tw2.jqplugins.chosen import ChosenSingleSelectField as SingleSelectField | |
except ImportError: | |
from tw2.bootstrap import SingleSelectField | |
class SubmissionForm(twb.HorizontalForm): | |
title = 'Submission' | |
assignment_id = twf.HiddenField() | |
submission_id = twf.HiddenField() | |
filename = twb.TextField(placeholder=u'Enter a filename, if needed', | |
help_text=u'An automatically generated filename may not meet the '\ | |
'language\'s requirements (e.g. the Java class name)', | |
css_class='span3') | |
source = twb.TextArea(placeholder=u'Paste your source code here', | |
css_class='span7', rows=10) | |
source_file = twb.FileField(css_class='span7') | |
language_id = SingleSelectField(options=[], prompt_text=None, | |
css_class='span3', | |
required=True, validator=twc.Required) | |
def prepare(self): | |
self.child.c.language_id.options = [(l.id, l.name) for l in self.value.assignment.allowed_languages] | |
super(SubmissionForm, self).prepare() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment