Skip to content

feat: add conditional fields and more source variants to FormBuilder - #463

Open
danielo515 wants to merge 2 commits into
masterfrom
claude/lucid-volta-kPm1p
Open

danielo515 wants to merge 2 commits into
masterfrom
claude/lucid-volta-kPm1p

Conversation

@danielo515

Copy link
Copy Markdown
Owner

Summary

Fills a few gaps in the programmatic FormBuilder API so it matches what the form editor UI and schema already support:

  • Conditional fields (Closes Set conditionals when using Form builder #385) — every builder method now accepts an optional condition: input.Condition, so you can do:
    builder("example")
        .text({ name: "trigger" })
        .text({
            name: "child",
            condition: { dependencyName: "trigger", type: "isSet" },
        })
        .build();
  • selectFromNotes({ name, folder }) — previously select was locked to the fixed source; this is the notes-backed variant.
  • multiselectQuery({ name, query, allowUnknownValues? }) — multiselect whose options come from a Dataview query (matches MultiSelectQuerySchema).
  • multiselectNotes shortcut — addMultiselectNotesField already existed but had no short alias alongside the other multiselect/select/etc. shortcuts. Now it does.

Under the hood, the existing methods were refactored to use a ...rest spread over FieldArgs so the new condition option flows through without changing their public signatures.

Test plan

  • npm run build (lint + svelte-check + esbuild production bundle) passes — 0 errors, only pre-existing warnings
  • npm run test — 167 tests pass (was 159, +8 new), 2 pre-existing skipped
  • Preview URL: build the plugin via the dev vault and run a short script using modalForms.builder with .selectFromNotes(...), .multiselectQuery(...), and a condition: on a field to confirm the built FormDefinition shape opens without validation errors

https://claude.ai/code/session_011up9cgw8Q9B38umdVuonM9

The programmatic FormBuilder API had a few gaps compared to what the form
editor UI and schema already supported:

- No way to attach a `condition` to a field, so there was no programmatic
  equivalent of "show this field only when another one is set" (Closes #385).
- `select` was always `fixed`-source — no way to build a select whose
  options come from notes in a folder.
- `multiselect` was always `fixed`-source — no way to build a multiselect
  whose options come from a Dataview query.
- `addMultiselectNotesField` existed but had no short alias alongside the
  other `multiselect`/`select`/etc. shortcuts.

Adds `condition` to the shared `FieldArgs` so every builder method
forwards it, plus `addSelectFromNotesField`/`selectFromNotes`,
`addMultiselectQueryField`/`multiselectQuery`, and a `multiselectNotes`
shortcut. Refactors the existing methods to use a `...rest` spread so the
new option flows through without changing their public signatures.

https://claude.ai/code/session_011up9cgw8Q9B38umdVuonM9

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps

greptile-apps Bot commented Apr 22, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR expands the programmatic FormBuilder API to match existing form capabilities. The main changes are:

  • Adds optional conditions to every builder method.
  • Adds notes-backed select fields.
  • Adds Dataview-backed multiselect fields.
  • Adds the missing multiselect-notes shorthand.
  • Adds tests for the new field shapes and defaults.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
src/core/FormBuilder.ts Adds conditional fields and new select and multiselect variants while preserving schema-compatible field shapes.
src/core/FormBuilder.test.ts Covers the new source variants, shorthand, defaults, and conditional-field output.

Reviews (2): Last reviewed commit: "Merge branch 'master' into claude/lucid-..." | Re-trigger Greptile

This branch has not been deployed

No deployments
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.

Set conditionals when using Form builder

2 participants