1. Go to this page and download the library: Download artisanpack-ui/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/ */
use ArtisanPackUI\Forms\Events\FormCreated;
use ArtisanPackUI\Forms\Events\FormSubmitted;
use ArtisanPackUI\Forms\Events\SubmissionDeleted;
// Listen for form submissions
Event::listen(FormSubmitted::class, function ($event) {
// $event->submission contains the submission
// $event->form contains the form
});
use function addFilter;
addFilter('ap.forms.fieldTypes', function (array $types) {
$types['my-custom-field'] = [
'label' => 'My Custom Field',
'view' => 'my-package::fields.custom',
'settings' => ['option1', 'option2'],
];
return $types;
});
use ArtisanPackUI\Forms\Services\IntegrationService;
use function addAction;
use function addFilter;
// Wrap every rendered field in a diagnostic marker
addFilter('ap.forms.fieldRender', function (string $html, $field): string {
return '<div data-field="' . $field->name . '">' . $html . '</div>';
});
// Observe integration registration from a third-party package
addAction('ap.forms.integrationRegistered', function (string $slug, array $config): void {
logger()->info("forms integration registered: {$slug}", $config);
});
// Register your own integration from your service provider boot()
app(IntegrationService::class)->registerIntegration('mailchimp', [
'label' => 'Mailchimp',
'icon' => 'o-envelope',
]);