1

Topic: Read only forms

Hi,

I was wondering whether there is any built-in provision to make forms read-only - i.e. make all form inputs read-only/disabled and not have a save button or data submission? This would be so that unauthorized people could see a form without changing it.

I have made some read-only variations of our data-entry forms using javascript to disable components, but this isn't really a satisfactory approach and it would be better if the read-only nature of the form is set when it is generated.

Would it make sense for all forms to have an optional read-only argument that could then be used to select appropriately disabled controls. This would require that each input control would need to optionally return a read-only alternative when the form is in read-only mode.

cheers

Robin

Robin Jones
IT Manager: Species Conservation
Wildfowl & Wetlands Trust

2

Re: Read only forms

All I know of is a provision for making text_inputs read only. You supply an option 'readonly="readonly"' to the input to use it.

I can imagine achieving this more generally by adding a set of read-only templates for controls in the $indicia_templates array located in helper_base. For each input template like 'textarea', 'checkbox', 'select', etc create the read-only version with the same name and a suffix of '-ro'. Then, in the apply_template function, if a readonly option is passed in to the function then '-ro' is appended to the template name that has been passed in.

That could then be used on a per-input basis if required but you could imagine an option in a Drupal form that would apply it to all inputs.

Alternatively, for a simple option, you could take a screenshot of the form and just show an image to users who are not logged in.

Jim Bacon.


F

3

Re: Read only forms

Hi Jim,

using -ro templates sounds like a really good approach. I guess that it would need some way to prevent disabling of some controls such as navigation buttons and tabs and there are other issues such as preventing some map interaction and form submission.  I guess it would be fairly easy to link this to user permissions so that a person with read-only rights would be served the read-only version.


What do others think about whether read-only versions of forms would be a useful feature for them to have? Our existing javascript solution is good enough for the moment , but for the future I think that an integrated solution would be really good.

cheers

Robin

Robin Jones
IT Manager: Species Conservation
Wildfowl & Wetlands Trust

4

Re: Read only forms

Hi Robin
I think it would be useful. I note though that there is a flag called MODE_EXISTING_RO for marking dynamic_sample_occurrence forms as readonly - if you search the code you should find it. I'm not sure if this implementation is quite what is needed though as it isn't a bit of code I've worked on, but it might be worth exploring.
Regards
John

John van Breda
Biodiverse IT

5

Re: Read only forms

Interesting. I don't remember seeing that before. It just removes the submit button by the look of it.
This feature would be a low priority for me at present.

Jim Bacon.