Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
How to change the select list to radio button in "Select a Product"?
Can I change the text of "Select a Product"?
How to change the select list to radio button in "Select a Product"?
Can I change the text of "Select a Product"?
Comments
Comment #1
rszrama CreditAttribution: rszrama commentedYou'd have to alter the Add to Cart form in a custom module; there's no place to do this in the UI.
Comment #2
jessicakoh CreditAttribution: jessicakoh commentedIs there an existing module for this already?
Does this guy's code look OK? http://drupal.org/node/1343192 If yes, I should try to make my own module.
I have tried searching http://www.drupalcommerce.org/contrib. It's challenging to click through 10s of pages. Is it possible you add a "search field" or a "display all"? :)
Comment #3
rszrama CreditAttribution: rszrama commentedThat code will work for the product select list shown in conjunction with product attributes. You'll need a different variable for a standalone product list,
$form['product_id']
.Comment #5
konordo CreditAttribution: konordo commentedComment #6
rszrama CreditAttribution: rszrama commentedJust remember to sanitize the #options values when you change it to radios.
Comment #7
jessicakoh CreditAttribution: jessicakoh commentedWhat do you mean by "sanitize"? :)
initialize the variable?
Comment #8
rszrama CreditAttribution: rszrama commentedNope, iterating over the #options array and passing the values through check_plain() to ensure HTML / JS is escaped properly.
Comment #9
facine CreditAttribution: facine commentedI am developing a module that you may be interested.
http://drupal.org/sandbox/facine/1687512
a greeting
Comment #10
rszrama CreditAttribution: rszrama commentedThese are the code comments for the select list the code above alters:
Comment #11
jessicakoh CreditAttribution: jessicakoh commentedWill take a look and try it out. Thank you. I love open source. Everyone can chip in.
Comment #12
konordo CreditAttribution: konordo commentedThank you for your feedback Ryan! Here's the updated code where options are sanitized:
@jessicakoh: Sanitize = convert to plain text -> remove html / js. Without this, html / js included in product titles will render in product options, posing a security threat.