Skip to main content
Forms · Revision #1

How do I create a custom form in the account area?

How do I create a custom form in the account area?

To create a form you need to create a class that extends the \Aero\AccountArea\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.

For example, here's how the login form is defined:

class LoginForm extends \Aero\AccountArea\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');
    }
}

Don't forget to register your form:

\Aero\AccountArea\AccountArea::registerForm(MyForm::class);