How do I disable a button conditionally in HEEX?

I found the answer here: Interpolating boolean attributes in HEEx - #4 by jaimeiniesta

Apologies for not searching more assiduously before asking a question in the forums.

Here is what my HEEX looks like now:

<button phx-click="save" name="save" value={@sheet_id} disabled={not @valid_sheet}> 
        Save
</button>

This will result in the disabled attribute disappearing entirely (rather than being set as disabled="false"), which is what I wanted.

8 Likes