Here is the quote_task field in simple form.
<%= f.input :quote_task, :label => t('Quote Task'), :input_html => {:value => @quote_task.id}, :readonly => true %>
Now we want to add an embeded html link for the @quote_task.id to show the content of the quote_task. When a user click the id, he will be directed to the content of the quote task. Something like:
<%= f.input :quote_task, :label => t('Quote Task'), :input_html => {:value => (link_to @quote_task.id.to_s, quote_task_path(@quote_task.id))}, :readonly => true %>
Is there a way to do this in simple_form? Thanks for help.
it's not possible to embed anchors within input fields.
you can use javascript to do whatever magic that field should have.
if you want to find out more about javascript. go to amazon, buy a book, read it.
your expectation for HTML are way beyond any possible semantic.
http://www.w3schools.com/tags/tag_input.asp http://www.w3.org/html/wg/drafts/html/master/forms.html#the-input-element
Yes it is possible that when one click on a input, it will show desired content. However without JS this wont be possible
input:
coffee script using jQuery:
simple solution, but better would be if you load some content from server to your page with Ajax http://api.jquery.com/jQuery.ajax/
but my opinion is that you shouldn't do this at all. Inputs are for forms, forms are for submitting data. What you should be really using is pure
link_to
without any input due to HTML semantics. If you want it to look like input that you can style it to look like input, point is don't rapeinput
tag for what it not meant to do.