PHP code example of developwithwp / omg-forms

1. Go to this page and download the library: Download developwithwp/omg-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/ */

    

developwithwp / omg-forms example snippets


if ( file_exists( get_template_directory() . '/vendor/autoload.php' ) ) {
    

$args = [
	'name'              =>  'contact-form',
	'redirect'          =>  false,
	'email'             =>  false,
	'form_type'         =>  'basic-form',
	'success_message'   =>  'Thank you!',
	'fields' => [
		[
			'slug'      =>   'your-name',
			'label'     =>   'Your Name',
			'type'      =>   'text',
			'

echo \OMGForms\Core\display_form( 'my-form-name' );

'groups'    => [
            [
                'id'        => 'group_1',
                'title'     => esc_html__('Group One Title', 'text-domain'),
                'order'     => '1',
                'class'     => 'my-group-class'
            ],
            [
                'id'        => 'group_2',
                'title'     => esc_html__('Group Two Title', 'text-domain'),
                'order'     => '2'
            ]
        ]

'fields' => [
    [
        'slug'          =>  'my-slug',
        'type'          =>  'select',
        'label'         =>  esc_html__( 'My Select', 'text-domain'),
        'class'         =>  'my-select-class',
        'template'      =>  'my-select.php',
        'placeholder'   =>  esc_html__( 'Select Placeholder', 'text-domain' ),
        'options'       =>  [
            [
                'value' =>  'value_1',
                'label' =>  esc_html__( 'Value One', 'text-domain' )
            ],
            [
                'value' =>  'value_2',
                'label' =>  esc_html__( 'Value Two', 'text-domain' )
            ]
        ],
        'group'         => 'group_1'
    ],
    [
        'slug'          =>  'my-number',
        'type'          =>  'number',
        'label'         =>  esc_html__( 'My Label', 'text-domain'),
        'class'         =>  'my-class',
        'template'      =>  'my-template.php',
        'group'         =>  'group_1',
        'sanitize_cb'   =>  'absint'
    ]
]