jramnani

jramnani

Hello,

I am almost done going through the book, Programming Phoenix 1.4, again after a hiatus from using Elixir for a few years.

It seems that Phoenix has changed a lot since I last used it around version 1.2, especially the view layer with Phoenix.Component and HEEx templates.

I did my best to get caught up and translated the examples from the book using the new view layer style with components.

You can find my work on GitLab here:

My style is a little different from the authors, but hopefully the examples are close enough to get you unstuck. Please don’t mind the commit messages as I leave breadcrumbs for me to remember things when I come back to this work and refresh my memory.

I am posting here about it, because I thought maybe someone else might be working through the book, and could use some help translating from old to new. I hope folks find this useful, until the book has a chance to be updated.

I hope you’re having a nice day.

Showing Posts 1 to 3

realcorvus

realcorvus

Thank you for posting this, it’s extremely helpful for people learning Phoenix. Mis-match between the code in the book and the current version is frustrating, great work!

Orzech

Orzech

Thanks for posting this, @jramnani!

Does category input select in lib/rumbl_web/controllers/video_html/video_form.html.heex work fine for you?

When I use your code as is, the select neither has the proper value selected when opening edit video page, nor the changeset contains changed category_id when I save updated video.

When I use value={f.data.category_id}, the form has category value properly selected when opening edit video page, but still the changeset does not contain changed category_id when I save updated video.

Orzech

Orzech

Replacing

<.input
  field={{f, :category_id}}
  name="category"
  type="select"
  label="Categories"
  prompt="Enter a category"
  options={Enum.map(@categories, fn c -> {c.name, c.id} end)}
  value={Enum.map(@categories, fn c -> c.id end)}
  />

from here with

<.input
  field={f[:category_id]}
  type="select"
  label="Categories"
  prompt="Enter a category"
  options={Enum.map(@categories, fn c -> {c.name, c.id} end)}
  />

is what fixed the problem on Phoenix 1.7.7 for me.

— All posts loaded —

Where Next? Top

Trending in Other Resources Top

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews