robinvdvleuten
How can I add a class to each select generated by date_select? I already created a custom builder but I can’t figure out how to add a class name to each select element;
builder = fn b ->
~e"""
<div class="flex">
<%= b.(:day, []) %>
<%= b.(:month, []) %>
<%= b.(:year, []) %>
</div>
"""
end
Thanks in advance for any help!
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted”
Version...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
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
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 12 to 3- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
ion
thank you so much for your detailed response! that explains it perfectly.
peerreynders
You provided this as your reference case:
My purpose was to attempt to generate equivalent HTML output with a builder function.
So if we start out with (in
iex):We’ll get this output:
Note how the “2020”, “12” and “25”
optionelements have theselectedattribute.Now a builder version:
which produces the same output.
EDIT:
Now having seen this code:
https://github.com/phoenixframework/phoenix_html/blob/v2.13.0/lib/phoenix_html/form.ex#L1391-L1395
This works as expected:
If you look at the
date_selectcode it should become obvious that the:defaultvalue has already been extracted and is being handed to thebuilderfunction as the value to format.By the time
builderruns it’s too late to influence the:defaultbecausehas already happened.
ion
I appreciate the detailed response, thank you. I tried using the
value:option key in the builder function for the:year, but it always returns current year, even on aneditaction when a value other than current year was set. With your version using the~Esigil, is it using the default year invalue:if one was not already set (i.e., empty list)?Thank you again.
peerreynders
An HTML input element has no notion of
default- that concept exists only in the context of the helper function. On the input level you have to set thevalueattribute.For
HTMLInputElement.defaultValue:So presumably the input element “remembers” the
valuethat was set when it was created as the “default”.Similiarly:
<select> HTML select element - HTML | MDN
HTMLSelectElement - Web APIs | MDN
<option> HTML option element - HTML | MDN
HTMLOptionElement - Web APIs | MDN
ion
sorry for the post bump, but does anyone know a solution?
ion
I am using the builder option instead of the built in helper function (shown below) to control the styling and order of the select fields. However, I’m trying to add a default option for the year to the builder, but have not found a solution.
To get a data range, I’m doing
but the following
defaultoption is not working.How can I add a default year to the builder while also supplying a range (shown above)?
peerreynders
Note to self - trying stuff out …
robinvdvleuten
Thanks @voughtdq, that did the trick!
voughtdq
robinvdvleuten
Are you guys sure? I tried it in several combinations and none of them adds the class to the generated html output (<%= date_select f, :date, class: “select” %>).