Milk Admin

Getting Started with Forms

Revision: 2025/10/18

This tutorial will guide you through creating forms in MilkAdmin. You can create forms automatically starting from the Model with the Builder or manage them manually with the framework classes.

FormBuilder

The fastest way to create forms in MilkAdmin is to use the FormBuilder, which automatically generates form fields from the Model structure.

Basic Example

Starting from an already configured model, you can create a complete form simply by writing:

use Builders\FormBuilder;
use App\{Response, Abstract\AbstractModule};
class ProductModule extends AbstractModule {
    #[RequestAction('edit')]
    public function actionEdit() {
        $form = FormBuilder::create($this->model)->getForm();
        Response::render($form);
    }
}
✅ Done! With these few lines you have a complete form with:
  • All Model fields
  • Automatic validation
  • Save button
  • CSRF token handling
  • Saving for new or modified records

To learn more about creating forms with the FormBuilder, consult the complete documentation at FormBuilder Class Documentation

Under the Hood

Behind the Form Builder there is a complete and accessible system for creating forms and validating data...

All of this part is also accessible separately and is documented in detail in the Forms category:

→ Introduction to Form Creation

Next Steps

🎉 Congratulations! Now you know how to create forms in MilkAdmin using the FormBuilder.

To learn more:

Loading...