-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Pre-select current tax category on product form #3936
Pre-select current tax category on product form #3936
Conversation
@@ -158,7 +158,7 @@ | |||
<%= f.field_container :tax_category do %> | |||
<%= f.label :tax_category_id, Spree::TaxCategory.model_name.human %> | |||
<%= f.field_hint :tax_category, default_tax_category: @default_tax_category&.name %> | |||
<%= f.collection_select(:tax_category_id, @tax_categories, :id, :name, { include_blank: t('spree.match_choices.none'), selected: @default_tax_category&.id }, { class: 'custom-select' }) %> | |||
<%= f.collection_select(:tax_category_id, @tax_categories, :id, :name, { include_blank: t('spree.match_choices.none'), selected: f.object.tax_category_id || @default_tax_category&.id }, { class: 'custom-select' }) %> |
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.
What about setting the default on @product.tax_category
at the controller level?
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.
sure, that's an option. Both solutions look rather equivalent to me. While the view gets simpler (we can entirely remove the selected
specification here) the controller gains a before_action
for both edit and new.
I've updated the code, let me know what you think!
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.
I like this way! Let see if others have opinions as well.
The `tax_category` select on the product form page should pre-select the default category only when the product does not have a tax category yet. If it does, then the current product tax category should be pre-selected, instead of the default one.
28eb286
to
b30c04b
Compare
Hello all,
I cant under stand what you sent here ????
*Mohammad Ali*
*CEO & Founder | YalaShoghol*
Phone: *0792291616* <0792291616>
Website: *www.yalashoghol.com* <http://www.yalashoghol.com/>
Email: *Mohammada@Yalashoghol.com* <Mohammada@Yalashoghol.com>
Address: *King Hussein Business Park #7 First Floor Yalashoghol*
…On Tue, 16 Feb 2021 at 10:12, Alberto Vena ***@***.***> wrote:
Merged #3936 <#3936> into master.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3936 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ARUIK3IL6JJLLOAXGR5PNUDS7ISF3ANCNFSM4XUPCOYA>
.
|
The
tax_category
select on the product form page should pre-select the default category only when the product does not have a tax category yet. If it does, then the current product tax category should be pre-selected, instead of the default one.Checklist: