Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
# Ignore vendor lib
vendor
node_modules
dist
dist
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,67 @@ if ( class_exists( '\Develtio\WP\Forms\Modules\Forms\CreateForm' ) ) {
}
```

## Use with AJAX ##
We use the Nette From library to building the forms (https://doc.nette.org/en/3.0/forms)

Example
```php
if ( class_exists( '\Develtio\WP\Forms\Modules\Forms\CreateForm' ) ) {
$options = [
'send_mail' => false, // enables / disables sending an email, enabled by default
'send_confirm_mail' => false, // enables / disables sending of confirmation email, disabled by default
'rest_api' => true, // enables / disables WP REST API endpoint for form
'create_cpt' => false, // enables / disables creation of CPT
];

$instance = new \Develtio\WP\Forms\Modules\Forms\CreateForm('StepFirst', $options);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$options has one tab and here is 2 tabs in the same if statement

$instance->form->addText('client_id')
->addRule($instance->form::REQUIRED, '<b>%name</b> is required');

$instance->form->addText('client_vat')
->addRule($instance->form::REQUIRED, '<b>%name</b> is required');

$instance->form->addText('client_phone')
->addRule($instance->form::REQUIRED, '<b>%name</b> is required')
->addRule($instance->form::MAX_LENGTH, "<b>%name</b> shoud be not longer than 12 numbers', 12 ");

$instance->save();
}
```


## Use with AJAX and Custom Handler ##
We use the Nette From library to building the forms (https://doc.nette.org/en/3.0/forms)

Example
```php
if ( class_exists( '\Develtio\WP\Forms\Modules\Forms\CreateForm' ) ) {
$options = [
'send_mail' => false, // enables / disables sending an email, enabled by default
'send_confirm_mail' => false, // enables / disables sending of confirmation email, disabled by default
'rest_api' => true, // enables / disables WP REST API endpoint for form
'create_cpt' => false, // enables / disables creation of CPT
'custom_handler' => [
'StepFirstHandleRequest',
plugin_dir_path(dirname(__FILE__)) . '/handlers/'
]
];

$instance = new \Develtio\WP\Forms\Modules\Forms\CreateForm('Step1', $options);
$instance->form->addText('client_id')
->addRule($instance->form::REQUIRED, '<b>%name</b> is required');

$instance->form->addText('client_vat')
->addRule($instance->form::REQUIRED, '<b>%name</b> is required');

$instance->form->addText('client_phone')
->addRule($instance->form::REQUIRED, '<b>%name</b> is required')
->addRule($instance->form::MAX_LENGTH, "<b>%name</b> shoud be not longer than 12 numbers', 12 ");

$instance->save();
}
```

## Templates ##

##### Form template #####
Expand Down
27 changes: 0 additions & 27 deletions composer.json

This file was deleted.

Loading