To create a form you need to create a class that extends the AccountAreaForm
class.
The $sections
array lists the views used to render the form.
The method
method defines the method that the form will use (this should be post
, get
, put
, or delete
).
The route
method should return the URL for the form. A $data
variable 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);
}
}