2011-11-11 3 views
2

중첩 모델 (:admin accepts_nested_attributes_for :account_setting)의 확인란이 몇 개 있습니다. 기본적으로 확인란의 레이블은 모델의 속성에서 생성됩니다. 하지만 로캘 폴더에 저장하는 사용자 지정 레이블을 키 값 쌍으로 사용하고 싶습니다. Formtastic을 사용하여 사용자 정의 레이블을 확인란에 지정

 

= semantic_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :validate => true, :html => { :method => :put }) do |f| 
    = f.input :email 
    = f.inputs :receive_email_digest, :as =>:check_boxes, :for => :account_setting, :label => 'My custom label' 
 

코드입니다 그리고 그것은 작동하지 않습니다. 나는 :input_html, :member_label을 시도했다.

formtastic suppor this this? 아니면 해킹해야합니까?

답변

1

inputs은 필드 집합입니다. formtastic에게 하나의 목록 항목과 입력 인 :receive_email_digest이있는 필드 세트 및 정렬 된 목록을 작성한다고 말하면서 저는 부울이라고 가정합니다. 여기서 :as은 실제로 영향을 미치지 않으며 :check_boxeshas_many에 대한 것입니다. 하나의 입력과 두 개의 필드 셋 각각 렌더링

= semantic_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :validate => true, :html => { :method => :put }) do |f| 
    = f.inputs do 
    = f.input :email 
    = f.inputs :for => :account_setting do 
    = f.input :receive_email_digest, :label => 'My custom label' 

:

당신은 뭔가를 원한다. 또는 아마도 even :

의미 필드는 범위이며 마크 업을 출력해서는 안됩니다.

나는 자원 이름이 자원 이름의 밑줄이 무엇이든간에 자원 이름이이 확인란의 레이블에 en.formtastic.labels.<resource_name>.account_setting.receive_email_digest을 사용한다고 생각합니다. 이 키 생성 방법은 the formtastic source을 확인하십시오.

+0

두 번째 솔루션이 작동했습니다. 고맙습니다. – Rahul

관련 문제