-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add additional subtypes, add None option, prefill edit with previously selected option. #1286
Add additional subtypes, add None option, prefill edit with previously selected option. #1286
Conversation
@ahatzz11 thanks for the update. Agree w/the organization here. For handling the nil value, I think we just need to remove that diff --git a/app/views/accounts/accountables/_investment.html.erb b/app/views/accounts/accountables/_investment.html.erb
index d403d99..9d97ced 100644
--- a/app/views/accounts/accountables/_investment.html.erb
+++ b/app/views/accounts/accountables/_investment.html.erb
@@ -1 +1 @@
-<%= f.select :subtype, options_for_select(Investment::SUBTYPES, selected: ""), { label: true } %>
+<%= f.select :subtype, options_for_select(Investment::SUBTYPES), { label: true, prompt: t(".prompt") } %>
diff --git a/config/locales/views/accounts/en.yml b/config/locales/views/accounts/en.yml
index b0b6421..56b386a 100644
--- a/config/locales/views/accounts/en.yml
+++ b/config/locales/views/accounts/en.yml
@@ -5,6 +5,8 @@ en:
has_issues: Issue detected.
troubleshoot: Troubleshoot
accountables:
+ investment:
+ prompt: Select subtype
credit_card:
annual_fee: Annual fee
annual_fee_placeholder: '99' |
Thanks for the suggestion! I've gone ahead and made that change as well. |
…nto new-investment-subtypes
@ahatzz11 I see what you're saying now. I think I misread the first time around. Rails forms should be able to populate this value automatically without much additional code. Let me take a deeper look at this and see what's going on. |
@ahatzz11 okay I figured out the issue. To leverage some of the Rails form magic, we need to remove <%# _depository.html.erb %>
<%= f.select :subtype, [["Checking", "checking"], ["Savings", "savings"]], { label: "Type", prompt: "Select subtype" } %> <%# _investment.html.erb %>
<%= f.select :subtype, Investment::SUBTYPES, { label: true, prompt: "Select subtype" } %> This should solve all the issues here:
|
@zachgoll Hey Zach, after playing with this for awhile I don't think that quite works (but if I'm doing something wrong please let me know). Here is what I see when running your code for the subtypes: I went back and forth on a bunch of options but for for the sake of not overcomplicating this I think the following should be true:
I did like how you removed the <%= f.select :subtype, Investment::SUBTYPES, { label: true, prompt: t(".prompt"), include_blank: t(".none") } %> I think the I couldn't find any nice way to have non-selectable helpertext on this ruby form, so this is where I landed: I also did this for depository! Happy to make any other changes you think would be good here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, think these changes make sense! Thanks for the help on this one.
Edit window with initial state of previously selected option:
![image](https://private-user-images.githubusercontent.com/6256032/375587206-207f2d6f-d94c-4765-baff-650c3bb92dbf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxODAwNDIsIm5iZiI6MTczOTE3OTc0MiwicGF0aCI6Ii82MjU2MDMyLzM3NTU4NzIwNi0yMDdmMmQ2Zi1kOTRjLTQ3NjUtYmFmZi02NTBjM2JiOTJkYmYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTBUMDkyOTAyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NDhlN2I2MWQ1M2NmZmQ4M2NiZTIwYTc4YTAzNTBkYjEwNTNmZDgyZDZkOTdmMDVhN2ZmOWRlMmI3Y2MyNTRkNyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.ZNuNx6VcJApC4V0DsmdCdo4rXgp50L08czzZZNj1veY)
I've been in software for a decade but have never touched ruby, so using this as a slow learning opportunity