PHP code example of jakesutherland / nomad-forms

1. Go to this page and download the library: Download jakesutherland/nomad-forms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jakesutherland / nomad-forms example snippets


$my_form = nomad_form( 'my_form_id', array(
	'method'   => 'POST',
	'callback' => 'my_form_callback',
	'fields'   => array(
		// Add your form fields here...
	),
) );

function nomad_fields( $id, $args ) {

	$defaults = array(
		'action'        => null,
		'method'        => null,
		'nonce'         => true,
		'form_tag'      => false,
		'submit_button' => false,
		'reset_button'  => false,
		'cancel_button' => false,
		'callback'      => null,
	);
	$args = wp_parse_args( $args, $defaults );

	return nomad_form( $id, $args );

}

/**
 * Fires when first initializing a Nomad Form.
 *
 * @since 1.0.0
 *
 * @param string $form_id The form ID being initialized.
 * @param array  $args    The form arguments.
 */
do_action( 'nomad/forms/init', $this->form_id(), $args );

/**
 * Filter the form arguments.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param array $args The form arguments.
 */
$args = apply_filters( "nomad/forms/{$this->form_id()}/args", $args );

/**
 * Filter the form fields.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param array $fields The form fields.
 */
$args['fields'] = apply_filters( "nomad/forms/{$this->form_id()}/fields", $args['fields'] );

/**
 * Filter form injections.
 *
 * It's recommended to use the `nomad_form_injection()` function instead of the filter directly.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param array $injections Form injections.
 */
$injections = apply_filters( "nomad/forms/{$this->form_id()}/injections", array() );

/**
 * Fires before the opening form tag.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( 'nomad/forms/before_form_open', $this );

/**
 * Fires before the opening form tag for a specific form.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( "nomad/forms/{$this->form_id()}/before_form_open", $this );

/**
 * Filters the opening form tag output.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param string     $output The opening form tag output.
 * @param Nomad_Form $this   The form instance.
 */
$output = apply_filters( 'nomad/forms/form_open', $output, $this );

/**
 * Filters the opening form tag output for a specific form.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param string     $output The opening form tag output.
 * @param Nomad_Form $this   The form instance.
 */
$output = apply_filters( "nomad/forms/{$this->form_id()}/form_open", $output, $this );

/**
 * Fires after the opening form tag for a specific form.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( "nomad/forms/{$this->form_id()}/after_open", $this );

/**
 * Fires after the opening form tag.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( 'nomad/forms/after_open', $this );


/**
 * Fires just after the `nomad_form_nonce` field in order to output
 * additional hidden fields.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( 'nomad/forms/hidden_fields', $this );

/**
 * Fires just after the `nomad_form_nonce` field in order to output
 * additional hidden fields of a specific form.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( "nomad/forms/{$this->form_id()}/hidden_fields", $this );

/**
 * Fires before the form fields container.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( 'nomad/forms/before_fields_container', $this );

/**
 * Fires before the form fields container for a specific form.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( "nomad/forms/{$this->form_id()}/before_fields_container", $this );

/**
 * Fires before the form fields.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( 'nomad/forms/before_fields', $this );

/**
 * Fires before the form fields for a specific form.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( "nomad/forms/{$this->form_id()}/before_fields", $this );

/**
 * Filters a specific form fields arguments.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param array      $field The form field.
 * @param Nomad_Form $this  The form instance.
 */
$field = apply_filters( "nomad/forms/{$this->form_id()}/field/{$field['name']}/args", $field, $this );

/**
 * Fires before a fields output.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this  The form instance.
 * @param mixed      $field The field being output.
 */
do_action( "nomad/forms/{$this->form_id()}/field/before", $this, $field );

/**
 * Fires before a fields output for a specific field.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this  The form instance.
 * @param mixed      $field The field being output.
 */
do_action( "nomad/forms/{$this->form_id()}/field/{$field['name']}/before", $this, $field );

/**
 * Fires after a fields output for a specific field.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this  The form instance.
 * @param mixed      $field The field being output.
 */
do_action( "nomad/forms/{$this->form_id()}/field/{$field['name']}/after", $this, $field );

/**
 * Fires after a fields output.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this  The form instance.
 * @param mixed      $field The field being output.
 */
do_action( "nomad/forms/{$this->form_id()}/field/after", $this, $field );

/**
 * Fires after the form fields for a specific form.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( "nomad/forms/{$this->form_id()}/after_fields", $this );

/**
 * Fires after the form fields.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( 'nomad/forms/after_fields', $this );

/**
 * Fires after the form fields container for a specific form.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( "nomad/forms/{$this->form_id()}/after_fields_container", $this );

/**
 * Fires before the form fields container.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( 'nomad/forms/after_fields_container', $this );

/**
 * Fires before the form actions.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( 'nomad/forms/before_form_actions', $this );

/**
 * Fires before the form actions for a specific form.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( "nomad/forms/{$this->form_id()}/before_form_actions", $this );

/**
 * Filters the submit button attributes.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param array      $submit_attributes The submit button attributes.
 * @param Nomad_Form $this              The form instance.
 */
$submit_attributes = apply_filters( 'nomad/forms/submit_attributes', $submit_attributes, $this );

/**
 * Filters the submit button attributes for a specific form.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param array      $submit_attributes The submit button attributes.
 * @param Nomad_Form $this              The form instance.
 */
$submit_attributes = apply_filters( "nomad/forms/{$this->form_id()}/submit_attributes", $submit_attributes, $this );

/**
 * Fires before the submit button.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( 'nomad/forms/before_submit_button', $this );

/**
 * Fires before the submit button for a specific form.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( "nomad/forms/{$this->form_id()}/before_submit_button", $this );

/**
 * Fires after the submit button for a specific form.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( "nomad/forms/{$this->form_id()}/after_submit_button", $this );

/**
 * Fires after the submit button.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( 'nomad/forms/after_submit_button', $this );

/**
 * Fires after the form actions for a specific form.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( "nomad/forms/{$this->form_id()}/after_form_actions", $this );

/**
 * Fires after the form actions.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( 'nomad/forms/after_form_actions', $this );

/**
 * Filters the reset button attributes.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param array      $reset_attributes The reset button attributes.
 * @param Nomad_Form $this             The form instance.
 */
$reset_attributes = apply_filters( 'nomad/forms/reset_attributes', $reset_attributes, $this );

/**
 * Filters the reset button attributes for a specific form.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param array      $reset_attributes The reset button attributes.
 * @param Nomad_Form $this             The form instance.
 */
$reset_attributes = apply_filters( "nomad/forms/{$this->form_id()}/reset_attributes", $reset_attributes, $this );

/**
 * Filters the cancel button attributes.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param array      $cancel_attributes The cancel button attributes.
 * @param Nomad_Form $this              The form instance.
 */
$cancel_attributes = apply_filters( 'nomad/forms/cancel_attributes', $cancel_attributes, $this );

/**
 * Filters the cancel button attributes for a specific form.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param array      $cancel_attributes The cancel button attributes.
 * @param Nomad_Form $this              The form instance.
 */
$cancel_attributes = apply_filters( "nomad/forms/{$this->form_id()}/cancel_attributes", $cancel_attributes, $this );

/**
 * Filters the closing form tag output.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param string     $output The closing form tag output.
 * @param Nomad_Form $this   The form instance.
 */
$output = apply_filters( 'nomad/forms/form_close', $output, $this );

/**
 * Filters the closing form tag output for a specific form.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param string     $output The closing form tag output.
 * @param Nomad_Form $this   The form instance.
 */
$output = apply_filters( "nomad/forms/{$this->form_id()}/form_close", $output, $this );

/**
 * Fires before the closing form tag for a specific form.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( "nomad/forms/{$this->form_id()}/before_form_close", $this );

/**
 * Fires before the closing form tag.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( 'nomad/forms/before_form_close', $this );

/**
 * Fires after the closing form tag for a specific form.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( "nomad/forms/{$this->form_id()}/after_form_close", $this );

/**
 * Fires after the closing form tag.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( 'nomad/forms/after_form_close', $this );

/**
 * Fires when a specific form is submitted successfully.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( "nomad/forms/{$this->form_id()}/success", $this );

/**
 * Fires when a specific form submission encounters an error.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( "nomad/forms/{$this->form_id()}/error", $this );

/**
 * Fires every time a form is submitted, regardless of whether
 * or not it was valid.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( 'nomad/forms/process', $this );

/**
 * Fires every time a specific form is submitted regardless of
 * whether or not it was valid.
 *
 * @since 1.0.0
 *
 * @param Nomad_Form $this The form instance.
 */
do_action( "nomad/forms/{$this->form_id()}/process", $this );

/**
 * Filter the form submission error messages for a specific form.
 *
 * Can only be used if the form allows modifications.
 *
 * @since 1.0.0
 *
 * @param array $error_messages The error messages generated when validating form fields.
 */
$error_messages = apply_filters( "nomad/forms/{$this->form_id()}/error_messages", $this->messages );