A textfield with #disabled = TRUE will appear greyed out, and be unchangeable.
A textfield with #input = FALSE will not send its value to $form_state['values'], and will be ignored by system_settings_form_submit().
Unfortunately, a textfield with #disabled = TRUE and #input = FALSE no longer appears greyed out.
I want to make a textfield that is purely for display purposes, so a person can copy a value from there. What is the best way to do this?
EDIT I: What I tried so far
To clarify, my starting point is code like this:
$form['thetext'] = [
'#type' => 'textfield',
'#title' => t('The text'),
'#disabled' => true, // This should make it greyed out - but it doesn't due to #input = false below.
'#input' => false, // This should make this field ignored in $form_state['values'].
'#value' => 'xyz', // Either #value or #default_value.
];
EDIT II:
If this wasn't clear before: I really want the html output to be a textfield element. I also want to use the regular form + theme API, so that the element gets a label and wrapper div and theming like other form elements in the same form. E.g. if I would just hardcode the textfield html, it would no longer have the same classes, wrappers etc.
<input>
if you don't want, well, input :) Output is arguably better left to tags/structures that suit that were designed for it. Take Digital Ocean as an example: when you hover over stuff that's useful to be copied, but can't be edited, a "copy" link appears to the right. Implementing something like that would be more pretty simple (a class and a few lines of JS), and it might, again arguably, be more idiomatic and better UI/X