Is it possible to set default values for the hidden and read-only fields? In particular, I want to be able to use this to hide the OG group field, but when I do, the field saves with a value of 0, instead of 1, which makes this a non-solution. I'm wondering if the default value settings needs to be done on the og.module side of things, or if it should be part of this module?

On a slightly related note, the front page mentions that the hidden widget is useful for cases where you want different edit forms for different users, but I can't figure out how this works. Does it still require a form_alter?

Comments

reubenavery’s picture

+1

However, I found that if I first set the widget to a regular type of widget, then go to default value and set that accordingly, and then go and flip it to 'hidden', it retains those default value(s)

colan’s picture

Status: Active » Closed (works as designed)

The field instance settings need to provide a default that you can set. This is what I'm doing for text fields. If you're using OG, then whatever OG field you care about needs to allow you set set a default.

To sum up, this is out of scope for Field extra widgets.

blainelang’s picture

Not being able to set the field value to me is a major deficiency. Here is a solution that does not use this module and was very easy to implement - https://www.silviogutierrez.com/blog/drupal-7-read-only-fields/

klonos’s picture

Title: Set default values for hidden and read-only fields? » Cannot set default values for hidden and read-only fields.
Category: Support request » Bug report
Issue summary: View changes
Status: Closed (works as designed) » Active
StatusFileSize
new4.97 KB
new10.31 KB

This is actually a bug and most likely #1956744: could not set default value is a duplicate ...although people there mention that they cannot change the default value of the field at all. For me (as for others here), switching the field widget to a core-provided widget ("text area" for example for long text fields) allows you to add/edit the default value and then you can switch the widget back to hidden (or read-only - but have not tested that).

Although the back-and-forth switching of widget types workaround works, it is not ideal UX. The goal of the module should be to hide the field widget from the edit form (for content authors) - not to disallow changing the default value from the content type edit form (site admins/builders).

So, the issue is that after setting a default value for a field and then setting it to hidden (also read-only I guess - have not tested that), one cannot change the default value of the field in the field settings form. So, instead of this:

drupal field_extrawidgets issue 1366762-default field value not allowed when widget set to hidden

...site builders should be seeing this:

drupal field_extrawidgets issue 1366762-default field value should be allowed when form widget set to hidden