Sacredceltic wrote:
> Thank you Tom,
> 
> but how do you pass the hidden_field values to the actual record
> attributes from my controller @person = current_user.person.build()
> 
> Say I want to pass the value to @person.sex, for instance ?

in the same way as you create other forms..

<% form_for(@person) do |f|%>
  <%= f.hidden_field :sex %>

then on icon you could set onClick="setSex('M', this)"

function setSex(gender, element) {
   document.getElementById('person_sex').value='M';
   // change class to make this selected/highlighted
   this.setAttribute("class", "highlited")
   // change other items
   ...
}

other way is to change radio buttons itself to images..
http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/

> 
> On Mar 11, 1:20 am, Tom Z Meinlschmidt <[email protected]> wrote:
>> Sacredcelticwrote:
>>> Hi,
>>> in a 'new' view for a persons model & controller, I want to be able to
>>> present a number of attribute options in the shape of icons. Each
>>> click on a different icon should set a given value to an attribute.
>>> For instance, if the user clicks on the icon for a "girl", I want the
>>> 'sex' attribute to be set to 'F' and the 'girl' icon to be somehow
>>> highlighted with a different border...
>>> When the user is satisfied with the options he set, he clicks on a
>>> submit button.
>>> I don't know how to pass the icon clicks as attribute values to my
>>> controller...
>> Just create hidden_field in your form and set it values from javascript
>> (onChange).. then submit the form and construct your query with these
>> values...
>>
>> tom
>>
>>> Thanks
>> --
>> =========================================================================== 
>> ====
>> Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache
>>
>> www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz
>> =========================================================================== 
>> ====
> 

-- 
===============================================================================
Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

www.meinlschmidt.com  www.maxwellrender.cz  www.lightgems.cz
===============================================================================

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to