form_tag를 사용하여 사용자가 축구 경기에 대한 예측을 입력 할 수 있고 조명기가 별도의 모델에서 가져온 것입니다. 예상치를 제출하면 어떻게할까요? 내가text_field_tag 내에 존재하는 경우 값 표시
을 사용하여 텍스트 입력을 사용하지 않도록 설정하는 방법에 대한 생각했다<%= form_tag controller: 'predictions', action: 'create', method: 'post' do %>
<% @fixture_date.sort.each do |date, fixture| %>
<ul class="fixture-dates">
<li><h5><%= date_format(date) %></h5></li>
</ul>
<ul class="fixtures">
<% fixture.each do |fixture|%>
<% if current_user.predictions.where(:fixture_id == fixture.id).empty? %>
<li>
<span class="home-team"><%= fixture.home_team %></span>
<span class="score">
<%= text_field_tag "predictions[][home_score]" %>
<%= text_field_tag "predictions[][away_score]" %>
</span>
<span class="away-team"><%= fixture.away_team %></span>
</li>
<%= hidden_field_tag "predictions[][home_team]", fixture.home_team %>
<%= hidden_field_tag "predictions[][away_team]", fixture.away_team %>
<%= hidden_field_tag "predictions[][fixture_date]", fixture.fixture_date %>
<%= hidden_field_tag "predictions[][fixture_id]", fixture.id %>
<% else %>
pre populated predictions against fixtures here
<% end %>
<% end %><!--if statement -->
</ul>
<% end %>
<%= submit_tag "Submit predictions", :class => "btn btn-success btn-large" %>
<% end %>
과 같이, 그들의 예측이 같은 읽기 전용 입력 필드를 가진 침묵 비품에 대해 미리 입력하는 것과 동일한 양식을 볼 다음 시간이 ..
양식 보인다
:disabled => true
하지만 사용자가 자신의 예측이 내가 자신의 예측으로 미리 채워 좋아할 이러한 두 개의 입력입니다하게되면 이것은 단지이 텍스트 그래서
{:disabled => true}
로 입력을 반환하는 것
<%= text_field_tag "predictions[][home_score]" %>
<%= text_field_tag "predictions[][away_score]" %>
누구든지 올바른 방향으로 나를 가리킬 수 있습니다
감사합니다
ED IT는
는지금은 장애인 옵션은 인수/값으로 이전 문을 걸리는 경우로 장애인 => 실제 출력은 {}, 워드 프로세서에서 보이는 이유 ... 알고 그래서 난이
'을 할 경우 ': name
, value
및 options
=> 사실
는 내가 text_field_tag
는 세 개의 인수를 허용하기 때문에
덕분에, 한이 이루어진 경우, 예를 들어 무기 호 대신에 내가 사용자의 예측을 통과 할 수 있도록? – Richlewis
@Richlewis 물론 –
current_user.predictions.home_score를 사용하여 사용자에 대한 예측에 액세스하려고합니다 : disabled => true이지만 점수에 액세스 할 수 없습니다 – Richlewis