Get a value of object field inside fields_for loop

后端 未结 2 528
野的像风
野的像风 2021-02-01 02:37

In the following scenario, I need to check the value of the object property in the fields_for loop.

<%= f.semantic_fields_for :review_details do          


        
相关标签:
2条回答
  • 2021-02-01 03:04

    I got it, I can use

    rd.object.review_criteria_id
    

    object is the default wrapper object for the fields_for loop.

    0 讨论(0)
  • 2021-02-01 03:06

    Formtastic adds additional features to the Rails code, but doesn't take away existing functionality so the following should work for you:

    rd.object.review_criteria_id
    

    'object' can be used in plain Rails form helpers to access the underlying bound object, and Formtastic honours this convention.

    0 讨论(0)
提交回复
热议问题