Developer Docs
  • Getting started
  • Tutorials
    • Integrate your theme with HivePress
    • Create a custom HivePress extension
  • Framework
    • Blocks
      • Callback
      • Container
      • Content
      • Form
      • Menu
      • Modal
      • Part
      • Section
      • Template
      • Toggle
    • Components
      • Cache
      • Helper
      • Request
      • Router
      • Translator
    • Configurations
      • Comment types
      • Image sizes
      • Meta boxes
      • Post types
      • Scripts
      • Settings
      • Strings
      • Styles
      • Taxonomies
    • Controllers
    • Emails
    • Fields
      • Checkbox
      • Checkboxes
      • Date
      • Date Range
      • Email
      • File
      • Number
      • Number Range
      • Password
      • Phone
      • Radio Buttons
      • Repeater
      • Select
      • Text
      • Textarea
      • Time
      • URL
    • Forms
    • Menus
    • Models
      • Making queries
      • Creating models
      • Customizing models
    • Templates
  • Resources
    • Code snippets
    • Code reference
    • Hook reference
    • REST API
Powered by GitBook
On this page
  • Parameters
  • Example

Was this helpful?

  1. Framework
  2. Blocks

Form

PreviousContentNextMenu

Last updated 2 years ago

Was this helpful?

This block type renders a .

Parameters

  • form - the name of a form to render;

  • redirect - true to refresh or URL to redirect the form on success;

  • values - optional field values to pre-fill;

  • attributes - the form HTML attributes.

Example

The code below renders the user registration form with an extra my-custom-class CSS class, and "user@example.com" default value in the Email field, refreshing the page on success.

echo ( new HivePress\Blocks\Form(
	[
		'form'       => 'user_register',
		'redirect'   => true,

		'values'     => [
			'email' => 'user@example.com',
		],

		'attributes' => [
			'class' => [ 'my-custom-class' ],
		],
	]
) )->render();

form