Hi,

I can easily prepopulate a CCK field with the help of this great module. I just wonder if I can make the field "read-only" after populating? I just want to lock the field for all users after populating the field, so that the prepopulated value can never be changed. Any ideas?

Cheers,
Sinan

Comments

daniel wentsch’s picture

Just what I was wondering, too.
Subscribing.

MacaroniDuck’s picture

Same here. Subscribing.

idflood’s picture

I think the issue is out of the scope of this module but here is how this could be solved. First create a module which implement hook_form_alter. In this hook you can add a property "#disabled" to a form element to make it uneditable but still visible.

As a side note, this should not be used as some kind of security check. The url is really too vulnerable for this.

hook_form_alter: http://api.drupal.org/api/drupal/modules--system--system.api.php/functio...
forms_api_ref: http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....

BeaPower’s picture

Is there an easier way for newbies?

Anonymous’s picture

Alternatively, one could also use hook_form_alter like this:

'#attributes' => array('readonly' => 'readonly')

which makes the text selectable but not editable which in turn might be safe but a little confusing for users.

jbrauer’s picture

This is somewhat related to #252053: Allow admins to hide prepopulated fields which anticipated not displaying the now "locked" field. Would your use case call for displaying the field without allowing the value to be changed on submission?

El Bandito’s picture

Hi

Ideally it would be possible to choose between prefilling and displaying as normal and editable, display the field but as read-only, or totally hide it. You knew the answer was going to be the worst case scenario, yes ?

Thanks for a great module.

El B

Norberto Ostallo’s picture

I have written a patch that solves this and other problems, you are welcome to test it and provide your feedback if you can. It applies to 7.x-2.x branch.
You can find it attached to this issue:
#1489526: Improve prepopulate behavior

fehin’s picture

I'm using this module with entity reference on user names. I would like to lock the field as I don't want users to change the referenced usernames.

nksahu’s picture

I wanted to hide title when it is prepopulated

I modified the prepopulate module like this

from:
       $form['#value'] = $requestslice ;

to

       $form['#value'] = $requestslice ;
       if ($form['#name'] == 'title'){
       	$form['#theme'] = 'hidden'; 
       }	

It works for me :)

jbrauer’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Closing D6 issues as it's no longer supported.