digestive-functors-0.7.1.5: A practical formlet library

Safe HaskellSafe-Inferred
LanguageHaskell98

Text.Digestive.View

Contents

Description

Provides functionality for frontend and backend integration.

This module contains functions used to glue form handling to particular server implementations and view libraries, defining the standard behaviour for handling GET and POST requests.

Field accessors can be used to write frontend libraries, mapping field values to concrete elements.

Synopsis

Documentation

data View v Source

Finalized form - handles the form, error messages and input. Internally handles the addressing of individual fields.

Constructors

forall a m . Monad m => View 

Instances

Functor View 
Show v => Show (View v) 

Obtaining a view

getForm :: Monad m => Text -> Form v m a -> m (View v) Source

Serve up a form for a GET request - no form input

postForm :: Monad m => Text -> Form v m a -> (FormEncType -> m (Env m)) -> m (View v, Maybe a) Source

Handle a form for a POST request - evaluate with the given environment and return the result.

Operations on views

subView :: Text -> View v -> View v Source

Returns the subview of a view matching the given serialized Path

subViews :: View v -> [View v] Source

Returns all immediate subviews of a view

Querying a view

Low-level

absolutePath :: Text -> View v -> Path Source

Determine an absolute Path for a field in the form

absoluteRef :: Text -> View v -> Text Source

Determine an absolute path and call fromPath on it. Useful if you're writing a view library...

Form encoding

viewEncType :: View v -> FormEncType Source

Returns the content type of the View - depends on contained fields

Input

fieldInputText :: forall v. Text -> View v -> Text Source

Return the text data at the position referred to by the given serialized Path.

fieldInputChoice :: forall v. Text -> View v -> [(Text, v, Bool)] Source

Returns a list of (identifier, view, selected?)

fieldInputChoiceGroup :: forall v. Text -> View v -> [(Text, [(Text, v, Bool)])] Source

Returns a list of (groupName, [(identifier, view, selected?)])

fieldInputBool :: forall v. Text -> View v -> Bool Source

Returns True/False based on the field referred to by the given serialized Path.

fieldInputFile :: forall v. Text -> View v -> Maybe FilePath Source

Return the FilePath referred to by the given serialized path, if set.

List subview

listSubViews :: Text -> View v -> [View v] Source

Returns sub views referred to by dynamic list indices at the given serialized path.

makeListSubView Source

Arguments

:: Text

ref

-> Int

index to use for the subview

-> View v

list view

-> View v 

Creates a sub view

Errors

errors :: Text -> View v -> [v] Source

Returns all errors related to the form corresponding to the given serialized Path

childErrors :: Text -> View v -> [v] Source

Returns all errors related to the form, and its children, pointed to by the given serialized Path.

Further metadata queries

Debugging

debugViewPaths :: View v -> [Path] Source

Retrieve all paths of the contained form