Forms
Creating forms
<?php
namespace HivePress\Forms;
use HivePress\Helpers as hp;
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
class Foo_Bar extends Form {
public function __construct( $args = [] ) {
$args = hp\merge_arrays(
[
// Set the form parameters.
'action' => hivepress()->router->get_url( 'custom_action' ),
'method' => 'POST',
'message' => 'Custom text',
'reset' => true,
// Set the field parameters.
'fields' => [
'custom_field' => [
'label' => 'Custom field',
'type' => 'text',
'required' => true,
'_order' => 123,
],
],
// Set the button parameters.
'button' => [
'label' => 'Custom button',
],
],
$args
);
parent::__construct( $args );
}
}
Customizing forms
Last updated