org.forms.fields

Classes

HtmlField

A textfield with html with integrated sanitation and annotation,

UploadOrLinkExistingFileField

An extension of onegov.form.fields.UploadFileWithORMSupport

UploadOrSelectExistingFileField

An extension of onegov.form.fields.UploadFileWithORMSupport

UploadOrSelectExistingMultipleFilesField

An extension of

Functions

file_choices_from_collection(→ list[tuple[str, str]])

Module Contents

class org.forms.fields.HtmlField(*args: Any, **kwargs: Any)[source]

Bases: onegov.form.fields.HtmlField

A textfield with html with integrated sanitation and annotation, cleaning the html and adding extra information including setting the image size by querying the database.

pre_validate(form: onegov.form.Form) None[source]

Override if you need field-level validation. Runs before any other validators.

Parameters:

form – The form the field belongs to.

org.forms.fields.file_choices_from_collection(collection: onegov.file.FileCollection[Any]) list[tuple[str, str]][source]
class org.forms.fields.UploadOrLinkExistingFileField(*args: Any, file_collection: type[onegov.file.FileCollection[Any]] = FileCollection, file_type: str = 'general', allow_duplicates: bool = False, _collection: onegov.file.FileCollection[Any] | None = None, **kwargs: Any)[source]

Bases: onegov.form.fields.UploadFileWithORMSupport

An extension of onegov.form.fields.UploadFileWithORMSupport which will select existing uploaded files to link from a given onegov.file.FileCollection class in addition to uploading new files.

This class is mostly useful in conjunction with onegov.org.forms.fields.UploadOrSelectExistingMultipleFilesField if you want to link or upload only a single file, then you should use onegov.org.forms.fields.UploadOrSelectExistingFileField.

existing_file: onegov.file.File | None[source]
widget[source]
allow_duplicates[source]
collection[source]
populate_obj(obj: object, name: str) None[source]

Populates obj.<name> with the field’s data.

Note:

This is a destructive operation. If obj.<name> already exists, it will be overridden. Use with caution.

create() onegov.file.File | None[source]
class org.forms.fields.UploadOrSelectExistingFileField(*args: Any, file_collection: type[onegov.file.FileCollection[Any]] = FileCollection, file_type: str = 'general', allow_duplicates: bool = False, _choices: list[tuple[str, str]] | None = None, **kwargs: Any)[source]

Bases: UploadOrLinkExistingFileField

An extension of onegov.form.fields.UploadFileWithORMSupport to allow selecting existing uploaded files from a given onegov.file.FileCollection class in addition to uploading new files.

Parameters:
  • file_collection – The file collection class to use, should be a subclass of onegov.file.FileCollection.

  • file_type – The polymoprhic type to use and to filter for.

  • allow_duplicates – Prevents duplicates if set to false. Rather than throw an error it will link to the existing file and discard the new file.

widget[source]
choices[source]
process_formdata(valuelist: list[onegov.form.types.RawFormValue]) None[source]

Process data received over the wire from a form.

This will be called during form construction with data supplied through the formdata argument.

Parameters:

valuelist – A list of strings to process.

class org.forms.fields.UploadOrSelectExistingMultipleFilesField(*args: Any, file_collection: type[onegov.file.FileCollection[Any]] = FileCollection, file_type: str = 'general', allow_duplicates: bool = False, **kwargs: Any)[source]

Bases: onegov.form.fields.UploadMultipleFilesWithORMSupport

An extension of onegov.form.fields.UploadMultipleFilesWithORMSupport to allow selecting existing uploaded files from a given onegov.file.FileCollection class in addition to uploading new files.

Parameters:
  • file_collection – The file collection class to use, should be a subclass of onegov.file.FileCollection.

  • file_type – The polymoprhic type to use and to filter for.

  • allow_duplicates – Prevents duplicates if set to false. Rather than throw an error it will link to the existing file and discard the new file.

widget[source]
upload_field_class[source]
upload_widget[source]
collection[source]
choices[source]
process_formdata(valuelist: list[onegov.form.types.RawFormValue]) None[source]

Process data received over the wire from a form.

This will be called during form construction with data supplied through the formdata argument.

Parameters:

valuelist – A list of strings to process.