form with readonly field
johnhelen - March 4, 2007 - 08:46
Hello
I need to have a edit form that includes some fields. One of the fields is not editable. I can use this in my html code
<input type="text" name=myText value="Enter Your Name" readonly>Could you please tell me how to do it using drupal
Many thanks
john

Webform module
Not sure what you're after but may be you can give webform module a try:
- http://drupal.org/project/webform
With this module you can design forms with different kind of fields. These forms can be submitted (as a result e-mails can be sent), and all data will be stored in the database.
___________________
discover new oceans
lose sight of the shore
#READONLY = true unavailable
I believe what johnhelen is getting at is that although drupal's form api supports the '#disabled' attribute, it doesn't support the 'readonly' attribute. They were both introduced in html 4.0 with the primary difference, I believe, is a disabled form input submits no value whereas a readonly input will submit the default value.
In my mind this is a bug in the form.inc of Drupal.
Try #attribute
I have not tried this in 4.7 but it works for 5.1
if you're using _form_alter hook
$form['account']['name']['#attributes'] = array('readonly' => 'readonly');or $form items
'#attributes' => array('readonly' => 'readonly');or use array('disabled' => 'disabled');
Chris Herberte