Cybo Advanced Field EngineCyboweb Technologies · Documentation · v1.0.2

Forms developer API

Functions

Function Does
cafe_dynamic_form( $form ) Prints a form (ID or arguments).
cafe_get_dynamic_form( $form ) Returns the form's HTML.
cafe_register_dynamic_form( $args ) Registers a form to use by ID.
cafe_submit_dynamic_form( $form, $data ) Validates and saves from PHP; returns a FormResult.

Shortcode: [cafe_dynamic_form id="…"] (registered forms and forms made in CAFE → Forms), optional object_id="…" (a number or current_user) for edit forms.

Arguments

Argument Default Notes
id required lowercase letters, digits, -, _
field_groups [] field group keys, in order
fields [] extra top-level fields by key or name
object_type post post, user, term, option
object_id 0 ID or object; current_user, current_post, current_term
mode derived create (posts only) or edit
post_type post created posts
taxonomy derived term forms
post_fields [] title, content, excerpt
post_terms [] taxonomies of the post type
post_status pending draft, pending, publish, private
submit_label Submit / Save changes
success_message built-in plain text
redirect '' {object_id} placeholder; same site only
ajax true
label_placement group's top, left
capability '' extra capability
allow_guests false create forms only
css_class '' extra classes on the <form>, space separated
intro_html '' text above the fields (HTML like in posts)
footer_html '' text below the fields, above the button

Wrong arguments give a WP_Error (cafe_form_invalid) from cafe_register_dynamic_form(), and a message for CAFE managers where the form would show.

Where forms come from

  1. Forms registered in PHP (cafe_register_dynamic_form()): they win when an ID is used twice.
  2. Forms made in CAFE → Forms (stored as private cafe_form posts; no CAFE tables change).
  3. Arguments passed directly to cafe_dynamic_form().

Arguments passed with the ID of a registered form add to its arguments: cafe_dynamic_form( [ 'id' => 'edit-event', 'object_id' => 42 ] ).

REST

See REST / headless.