Timeline for "Add to cart" form tweaks
Current License: CC BY-SA 3.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 9, 2014 at 13:20 | comment | added | gigabates | You could add another submit button with its own submit handler that redirects to the cart page. I think that a link is more semantically correct though is it's not really related to submitting the form. | |
| Mar 9, 2014 at 2:57 | comment | added | tukra | I figured out how to leave it as a link and style it to look like a button. Not that clean though since I have to duplicate the button css in the theme. Is there a better way? | |
| Mar 9, 2014 at 1:55 | comment | added | tukra | Okay this is starting to make more sense. I want a button that acts like an href to '{root}/cart/' $form['show_cart'] = array('#type' => 'button', '#value' => t('View cart'), '#attributes' => array('onclick' => 'window.location.href=\'cart\''), '#weight' => 65, ); but can't figure out how to get rid of the "submit" | |
| Mar 8, 2014 at 2:42 | vote | accept | tukra | ||
| Mar 8, 2014 at 2:37 | comment | added | gigabates | Sure. You can add a link to the form by adding something like this to the hook I posted: $form['show_cart'] = array('#markup' => l(t('Show Cart'), 'cart'), '#weight' => 99); All we're doing is adding elements to the form's render array after it's been built. | |
| Mar 8, 2014 at 2:25 | comment | added | tukra | Awesome. Thanks so much. Maybe I can start to understand how this works a little. Next I want to add a 'Show Cart' button adjacent to the 'Add to Cart' button. If you could give any help on how to do that or how any of this is working in general I'd find that really useful. | |
| Mar 8, 2014 at 1:46 | history | answered | gigabates | CC BY-SA 3.0 |