Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7958131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:22:26+00:00 2026-06-04T04:22:26+00:00

I feel like this should be really really simple, but I’m completely stuck! In

  • 0

I feel like this should be really really simple, but I’m completely stuck!

In a form I might have a field like:

<%= f.text_field :name, :class => "text" %>

On edit, this pulls back in the value submitted on create, that’s fine. But I want to prevent certain fields from being edited. I know I can disable the field or hide it, but I’d like to be able to pull in the values to display and use in other ways. How do I access them?

In this case I’ve tried things like:

<%= f.track.name %>

<%= track.name %>

<%= @track.name %>

But none of the above work!

Any ideas folks?

EDIT: (I’m using nested forms for this)

<%= form_for(@release, :html => { :multipart => true }) do |f| %>
    <h3>Upload Tracks for <%= @release.title %></h3>

    <%= f.fields_for :tracks do |builder| %>
    <%= render 'upload_track_fields', :f => builder %>
    <% end %>

<%= f.submit "Upload Tracks", :class => "submit" %>    
<% end %>

And the upload_track_fields that are rendered:

<%= f.text_field :position, :class => "text" %>
<%= f.text_field :name, :class => "text" %>
<%= f.text_field :isrc, :class => "text" %>
<%= f.text_field :version, :class => "text" %>
<%= f.file_field :track, :class => "text" %>
<%= f.hidden_field :primary_genre_id %>
<%= f.hidden_field :secondary_genre_id %>
<%= f.hidden_field :alt_primary_genre %>
<%= f.hidden_field :alt_secondary_genre %>
<%= f.hidden_field :asset_tier %>
<%= f.hidden_field :preview_start %>
<%= f.hidden_field :parental_advisory %>
<%= f.hidden_field :available_separately %>
<%= f.hidden_field :_destroy %>

I’ve hidden most of the fields to prevent editing, but still need to see some of the fields so they’re left as text fields. I tried to disable them, but that stops any changes (specifically the file upload) working.

In short, i’d prefer to display most of the above as text rather than form fields.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:22:27+00:00Added an answer on June 4, 2026 at 4:22 am

    In the main form:

    <% index = 0 %>
    <% f.fields_for :tracks do |builder| %>
      <%= @release.tracks[index].name %>
      <%= render 'upload_track_fields', :f => builder %>
      <% index += 1 %>
    <% end %>
    

    In the nested form:

    <%= f.text_field :position, :class => "text" %>
    # Notice that there's no "name" attribute
    <%= f.text_field :isrc,     :class => "text" %>
    <%= f.text_field :version,  :class => "text" %>
    <%= f.file_field :track,    :class => "text" %>
    

    What I did in the first snippet is dirty, but I never used fields_for so I don’t know how to get the actual index. I looked in Google, but I didn’t find a solution so far.

    I can’t try it right now, I’ll do it when I’ll be home.
    I suggest using this while finding a way to get the index.

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel like this might be really simple but I'm just not getting it
I feel like the answer to this question is really simple, but I really
Okay, if feel like this should be really simple and accomplished by a function
I feel like this should be a no brainer, but clearly I'm missing something...
I feel like this should be obvious to me, but for some reason I
I feel like this is something I should already know, but I'm just not
I feel like this must have been asked before, but I've looked at Knockout
I have a rather simple question for you.. I feel like I should have
To me it seems like it should be so simple, but I just feel
I feel like this is easy but I am missing something... Using jQuery, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.