Hello, on a user, I created test filed and assigned the format "read-only". When I edit the user, the field is not displayed.

Please note that I needed to alter something on line 119 as on my localhost, the
+= created an error.

Comments

damien tournoud’s picture

You should be able to go ahead and configure the formatter to use in the "Edit" section of the Field UI.

Not sure why the fallback default doesn't work for you.

jaxpax’s picture

Same here, Read-only doesn't show anything

amateescu’s picture

Status: Active » Needs work
StatusFileSize
new1.11 KB

Here's the patch that I used to get rid of the fatal error mentioned in the OP as I encountered it when creating a field with the Hidden widget as well.

Note that it doesn't fix the read-only field not being displayed..

plonk’s picture

Marked #1312788: Fatal error: Unsupported operand types in field_extrawidgets.module on line 119 as duplicate of this issue. Confirmed that @amateescu's patch in #3 resolved that issue

nevergone’s picture

Status: Needs work » Reviewed & tested by the community

Patch tested and works well.

amateescu’s picture

Status: Reviewed & tested by the community » Needs review

Sure, the patch works, but only for the fatal error.

I can't remember if I tried, but does it also fix the read-only field being hidden?

deryck.henson’s picture

Priority: Normal » Major
Status: Needs review » Needs work

This patch was unsuccessful in fixing the original problem (viewing the read-only field). Given that this is essentially half the reason this project exists, I feel the priority should be raised.

urlaub’s picture

Was anyone able to fix the original issue?
I installed the module to publish a read-only field in the edit form, but I have to confrim the bug, it's not working.
First I was using the module computed field and had the same issue, maybe someone can find a possible solution here: http://drupal.org/node/214197

damien tournoud’s picture

Merged #3 in 7.x-1.x.

rbennata’s picture

same problem for me - readonly is just hidden. For me, this is the use for this module.

joel_osc’s picture

FYI, my read-only field is also not displaying, but I figure it is because my field is part of a Field Collection which means this line of code will return an empty array instead of rendering the field because the entity type is field collection but the form_state only contains a reference to the node entity which has the field collection.

    179   if ($widget_type == 'field_extrawidgets_read_only') {
    180     // Clone the entity to avoid messing with it.
    181     $entity_type = $element['#entity_type'];
    182 
    183     if (!isset($form_state[$entity_type])) {
    184       return array();
    185     }

Makes sense to me that field collections would need to be explicitly supported, too bad it is not because this is a great module!

davidwhthomas’s picture

Same here,

I have a field using the "Ready only" widget.

The value is set programmatically, and visible in the db field table, but the field does not display on the entity edit form.

Looks like it needs work.

Edit: field shows on entity view, just not on edit form.

Anonymous’s picture

Title: read-only field is hidden » Contents of a read-only field is hidden on the node/entity edit form, and thus cannot be edited.
Version: 7.x-1.0-beta1 » 7.x-1.1
Priority: Major » Critical
StatusFileSize
new90.81 KB

The project notes state "Read-only: this widget shows the content of the field on the edit form".

This assertion is not true.

The module is not usable in its present state for this stated purpose.

Test of editing a read-only text field

Firemyst’s picture

StatusFileSize
new3.39 KB

I've been messing with this module for a day and saw, like everyone else, that the read-only option makes the entire value disappear. I made the following patch to fix the display for the read-only option.

Basically, it has to do with the visibility settings ('display_empty') removing the entire element if set not to show. This is the default behavior, so it looks like it's disappearing. By changing where the condition is shown, and adding a default #markup with the value first, I was able to solve this problem.

If this works for you, let me know. I consider it a WIP.

kasalla’s picture

Thanks for the patch.
Now it shows the value even it is empty (display_empty = 1).

But using a simple textfield, I cannot enter the read-only text anywhere.

Firemyst’s picture

Ah, to be honest, I hadn't thought of how to enter the data. Right now, I'm using it for showing data created by code in the database, where I wouldn't want an editor to mess with, like a shortened URL, for example.

Getting it to show as a valid text field in the Add content vs. Edit could be as easy as checking the node id, or the args. I can look into how do that when I have some free time, if no one else wants to give it a shot.

pdcrane’s picture

Issue summary: View changes

Still not resolved in -dev.

What's needed to push this patch through?

afoster’s picture

I applied patch in #14 to today's dev version and got this error. (2 errors per empty, read-only, visible fields).

Notice: Undefined index: value in field_extrawidgets_field_widget_form() (line 215 of /_work/PGA_pga.org/_website/sites/all/modules/contrib/field_extrawidgets/field_extrawidgets.module).
Notice: Undefined index: und in field_extrawidgets_field_widget_form() (line 215 of /_work/PGA_pga.org/_website/sites/all/modules/contrib/field_extrawidgets/field_extrawidgets.module).

Added is a revised version of #14 patch - I Added a check to if there is a value set, and if not applying an empty string.

Angry Dan’s picture

Status: Needs work » Needs review
StatusFileSize
new1.62 KB

I'm having trouble with field collection items. As far as I can tell, rather than reading $form_state[$entity_type] you just need to read $form['#object'] instead.

See attached patch.

Angry Dan’s picture

StatusFileSize
new1.64 KB

Sorry, for what was undoubtedly my worst contribution of the day! $element['#entity'] is what I meant.

Angry Dan’s picture

miroslavbanov’s picture

Title: Contents of a read-only field is hidden on the node/entity edit form, and thus cannot be edited. » Contents of a read-only field is hidden on the term/entity edit form, and thus cannot be edited.
Status: Needs review » Reviewed & tested by the community

For me, I have the same problem on the taxonomy_term form. The term is at key $form_state['term'] and it is searched at $form_state['taxonomy_term'].

Patch #20 fixes it nicely.

miroslavbanov’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.78 KB

Oops, I didn't realize until now, but this broke the field administration. New patch attached.

klonos’s picture

Status: Needs review » Reviewed & tested by the community

#23 works for me in the latest dev. Thanx.

mirondi’s picture

miroslavbanov’s picture

@mirondi, at least say something. Why the silent treatment?