# TinyLab View Rules
This document defines the view patterns and conventions used in TinyLab. Follow these rules when creating new views or modifying existing ones.
## 1. Directory Structure
```
app/Views/
├── layout/
│ ├── main_layout.php # Primary app layout (sidebar, navbar, dark mode)
│ └── form_layout.php # Lightweight layout for standalone forms
├── [module_name]/ # Feature module (e.g., patients, requests)
│ ├── index.php # Main list page
│ ├── dialog_form.php # Modal form (Create/Edit)
│ └── drawer_filter.php # Filter drawer (optional)
├── master/
│ └── [entity]/ # Master data entity (e.g., doctors, samples)
│ ├── index.php
│ └── dialog_form.php
└── errors/
└── html/
├── error_404.php
└── error_exception.php
```
## 2. Layout Extension
All pages must extend the appropriate layout:
```php
= $this->extend("layout/main_layout"); ?>
= $this->section("content") ?>
= $this->endSection(); ?>
= $this->section("script") ?>
= $this->endSection(); ?>
```
Use `form_layout.php` for standalone pages like login:
```php
= $this->extend("layout/form_layout"); ?>
```
## 3. Alpine.js Integration
### 3.1 Component Definition
Always use `alpine:init` event listener:
```php
= $this->section("script") ?>
= $this->endSection(); ?>
```
### 3.2 Alpine Data Attribute
Wrap page content in the component:
```php
Module description
Loading...
No data found
| # | Code | Name | Actions |
|---|---|---|---|
Select an item to view details