Fix foreign key cascades and add validation for missing AR fields
- Enable SQLite foreign key constraints to properly cascade deletes - Add validation to prevent adding products when no AR fields configured - Display helpful warnings on product pages when fields are missing - Redirect users to AR field configuration when needed
This commit is contained in:
@@ -10,6 +10,21 @@
|
||||
<h2>Add New Product</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if not custom_fields %}
|
||||
<div class="alert alert-warning" role="alert">
|
||||
<h4 class="alert-heading"><i class="bi bi-exclamation-triangle-fill me-2"></i>No Fields Configured</h4>
|
||||
<p>Unable to add products. You must configure custom AR fields before adding products.</p>
|
||||
<hr>
|
||||
<p class="mb-0">
|
||||
<a href="/{{ tenant_id }}/ar_fields" class="btn btn-primary">
|
||||
<i class="bi bi-gear-fill me-1"></i>Configure AR Fields
|
||||
</a>
|
||||
<a href="/{{ tenant_id }}/" class="btn btn-secondary ms-2">
|
||||
<i class="bi bi-arrow-left me-1"></i>Back to Products
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
{% else %}
|
||||
<form action="/{{ tenant_id }}/add" method="POST" enctype="multipart/form-data">
|
||||
<div class="mb-3">
|
||||
<label for="product_id" class="form-label">Product ID *</label>
|
||||
@@ -71,6 +86,7 @@
|
||||
<button type="submit" class="btn btn-primary">Add Product</button>
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user