Routing and Template Cookbook: Forms and processing

= Handlers =

Authas forms
Here is an example of getting an authas form from the controller:

The authas form is  inside of $rv and can be passed into the template.

Form authentication
Just like above, form authentication in handled in the controller:

If, for some justified reason, you have form submission and need there to be NO form authentication, you should explicitly do so:

Make sure to comment why this needs to happen.

You can, of course, combine both authas and form_auth in the controller call:

GET arguments
Contained in a request's :

POST arguments
Contained in a request's :

= Templates =

Authas forms
Authas forms--the forms that ask which journal/community a user is working on at the moment--should not be generated in the template. They should use the return value given by the controller above and passed in with the template variables:

Form authentication
Any POST method form will need to include a form authentication:

Textbox
[%- form.textbox( label = dw.ml( '.email.user' )       name = 'bounce_email'        size = 25 ) -%]

Checkbox
[%- form.checkbox( label = dw.ml( ".put.in.queue" )       name = "touch"        id = "touch" ) -%]

Select
Here is an example that creates the items array that it passes it in:

[% '.createlayer.layoutspecific.label.type' | ml %] [% layer_types = [ "theme", dw.ml( '.createlayer.layoutspecific.select.theme' ), "i18n", dw.ml( '.createlayer.layoutspecific.select.language' ), "user", dw.ml( '.createlayer.layoutspecific.select.user2' ), ] %] [% form.select( name = 'type', items = layer_types ) %]

It's also possible to just use an array given to the template by the handler.

Radio
Here is an example of a radio form input in a legend fieldset with two radio buttons:

[% ".label.post_as" | ml %] [%- form.hidden( id = "poster_remote", name = "poster_remote", value = remote.user ) -%] [%- form.radio( label = remote.user       name = "post_as"        id = "post_as_remote"

value = "remote" default = ( post_as == "remote" ) ) -%]   [%- post_as_other_label = ".label.post_as_other" | ml;    form.radio( label = post_as_other_label name = "post_as" id = "post_as_other"

value = "other" default = ( post_as == "other" ) ) -%]