# Capture form input from text\_field and modify data

**URL:** <https://discuss.rubyonrails.org/t/capture-form-input-from-text-field-and-modify-data/19700>\
**Category:** rubyonrails-talk\
**Created:** [October 25, 2007, 5:53pm UTC](https://discuss.rubyonrails.org/t/capture-form-input-from-text-field-and-modify-data/19700 "2007-10-25T17:53:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![biqut2](https://avatars.discourse-cdn.com/v4/letter/b/f475e1/32.png) [@biqut2](https://discuss.rubyonrails.org/u/biqut2)\
**Post date:** [October 25, 2007, 5:53pm UTC](https://discuss.rubyonrails.org/t/capture-form-input-from-text-field-and-modify-data/19700/1 "2007-10-25T17:53:53Z")

</div>

I'm new to ruby and just trying to toech myself ruby on rails. I've got a shopping cart and I need to be able te specify product quantity while in the cart. I have succefully created a link to incriment the quantity but I would like to be able to grab a number from a text\_field and use it as the new quantity. The incriment feature is implimented as follows:

This is in my view: \<%= link\_to("\<font color=green\>(add)\</font\>", :action =\> :update\_cart, :id =\> product.id) %\>

This is in my store controller: &nbsp;&nbsp;def update\_cart &nbsp;&nbsp;&nbsp;&nbsp;product = Product.find(params[:id]) &nbsp;&nbsp;&nbsp;&nbsp;@cart.update\_product(product) &nbsp;&nbsp;&nbsp;&nbsp;flash[:notice] = "Item quantity has been updated" &nbsp;&nbsp;&nbsp;&nbsp;redirect\_to(:action =\> :display\_cart) &nbsp;&nbsp;end

This is in my cart class: &nbsp;&nbsp;def update\_product(product) &nbsp;&nbsp;&nbsp;&nbsp;item = @items.find {|i| i.product\_id == product.id} &nbsp;&nbsp;&nbsp;&nbsp;item.quantity += 1 &nbsp;&nbsp;&nbsp;&nbsp;@total\_price += product.price &nbsp;&nbsp;&nbsp;&nbsp;@total\_shipping += product.shipping &nbsp;&nbsp;end

I'm clueless here and could really use some help. TIA
