Question

hopefully a simple question.

Is it possible to make the value of a simple_form field a link_to?

I have tried

 = f.input link_to(:project_id,project_path(@project_action_plan.project_id)), readonly: true

and also

= f.input :project_id, :input_html => {:value => link_to @project_action_plan.project_id, project_path(@project_action_plan.project_id)}, readonly: true

But am not getting the desired result.

Google only really brings up this stackoverflow result which was more about then using ajax etc and the simple_form Github doesn't mention anything. I am thinking it may not be possible and that I will have to make the label clickable.

Was it helpful?

Solution

The way the helper methods work is very specific. If you want to write your own custom helper then it's possible to create your own arbitrary formatter methods by creating a subclass of FormBuilder and using that when rendering your forms.

More information on this subject is available in the documentation on Form Helpers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top