How do I create a new form for the account area?
To create a form you need to create a class that extends the AccountAreaFormclass.
The $sectionsarray lists the views used to render the form.
The methodmethod defines the method that the form will use (this should be post, get, put, or delete).
The routemethod should return the URL for the form. A $datavariable is accessible in case the route requires parameters that are available in the data.
<?php
namespace Acme\MyModule;
use Aero\AccountArea\AccountAreaForm;
class MyForm extends AccountAreaForm
{
protected $sections = [
'email' => 'account-area::partials.email-input',
'password' => 'account-area::partials.password-input',
'forgot-password' => 'account-area::partials.login-forgot-password-link',
'submit' => 'account-area::partials.login-button',
];
protected function method(): string
{
return 'post';
}
protected function route($data): string
{
return route('login');
}
}
Registering a form
Any form you wish to use in the account area should be registered in your service provider.
<?php
namespace Acme\MyModule;
use Aero\AccountArea\AccountArea;
use Aero\Common\Providers\ModuleServiceProvider;
class ServiceProvider extends ModuleServiceProvider
{
public function setup(): void
{
AccountArea::registerForm(MyForm::class);
}
}