Skip to content

Conversation

@andreia
Copy link
Member

@andreia andreia commented Jan 30, 2026

Details

This PR addresses two issues related to material handling in steps:

  1. Correctly displays missing material errors: The step.blade.php view now distinguishes between intentionally text-only steps (where material_type is null) and steps where material was deleted (where material_type is set but the material record is missing). An error message is now displayed when material is missing but a material_type was specified.
  2. Enforces material selection in form: The MorphToSelectWithCreate component now uses requiredWith('material_type') for the material_id field. This prevents users from selecting a material_type without also selecting an actual material item, ensuring data consistency.

Note

Low Risk
Low risk: view logic and form validation tweaks to prevent inconsistent step/material states; main risk is stricter validation blocking previously-saved partial entries.

Overview
Improves step material consistency by treating material_type = null as an intentionally text-only step (shows only the next button) while showing an explicit error state when material_type is set but the linked material record is missing.

Tightens the step material form by making material_id requiredWith('material_type'), preventing users from selecting a material type without choosing an actual material.

Written by Cursor Bugbot for commit d2b7e39. This will update automatically on new commits. Configure here.

- Bug 1: In step.blade.php, distinguish between intentionally text-only steps
  (material_type is null) and steps with deleted material (material_type is set
  but material record doesn't exist). Now shows error for deleted material
  regardless of whether text exists.

- Bug 2: In MorphToSelectWithCreate.php, change material_id from nullable() to
  requiredWith('material_type') to prevent invalid state where material_type is
  selected but material_id is null.
@andreia andreia merged commit cd81152 into allow_nullable_material_on_step Jan 30, 2026
4 of 8 checks passed
@andreia andreia deleted the cursor/step-material-consistency-8a6f branch January 30, 2026 01:05
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before Autofix could start.

<x-filament-lms::next-button :fixed="false" />
@if (is_null($step->material_type))
{{-- Intentionally text-only step: show the next button --}}
<x-filament-lms::next-button />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty steps no longer display error message

Low Severity

The old code showed an error message when a step had no material AND no text content. The new code assumes material_type being null indicates an intentional text-only step, but it no longer verifies text actually exists. Since the text field in StepResource isn't required, steps with material_type = null and no text will display only a next button with no visible content, instead of showing the error message the old code provided.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants