Hello,
I am writing a module, that creates node type. Node includes also a multiple media field. When I install my module node type is there, it has all created fields, but if I go to node edit form just media field is missing. Field itself is defined in another module, while instance is defined in module that creates node type. First module is dependency to second one. Here is my definition of field and it's instance:
<?php
//field definition
$fields['delo_title_image'] = array(
'field_name' => 'delo_title_image',
'type' => 'media',
'cardinality' => 0,
'translatable' => TRUE,
'settings' => array(),
);
//instance definition
$instances['delo_title_image'] = array(
'field_name' => 'delo_title_image',
'label' => $t("Title image(s)"),
'description' => $t("Title image(s) for content. "),
'required' => true,
'widget' => array(
'type' => 'media_generic',
'weight' => 5,
),
'display' => array(
'default' => array(
'label' => 'hidden',
'type' => 'media_link',
'weight' => 5,
),
),
);
?>
Widget appears if I go to "Manage fields" page, open edit form for this field and save it. This does not fix the problem completely, since I get a fatal error when trying to preview created node.
PHP Fatal error: Cannot use object of type stdClass as array in /var/www/modules/field/field.form.inc on line 193, referer: http://polet.anna.delo.si/node/add/article?render=overlay&render=overlay
Can you tell me what am I doing wrong?
Comments
Comment #1
rogueturnip commentedI'm in the same boat. Would like to know how to do this. Maybe a list of the different display types and widget types might help too.
THanks!
Comment #2
slashrsm commentedI was also playing with different configuration and settings... but no success.
Comment #3
bryancasler commentedSubscribe, my blog entry page now permanently displays the error
Inactive fields are not shown unless their providing modules are enabled. The following fields are not enabled:media (field_media) field requires the media_generic widget provided by media moduleI even uninstalled the media module, the error is still persisting.
Comment #4
AgaPe commentedgot my issue solved by updating the `field_config` database table,
set 'module' to your field module if its wrong (for me image was somehow change to audiofield) and 'active' to 1
Comment #5
bryancasler commentedAgaPe could you tell in more detail how I could resolve this. Heads up, I'm not familiar with working directly in the DB.
Comment #6
AgaPe commentedDo you have access to phpmyadmin or sth like that? then its just clicking the right table, edit the right row
Comment #7
bryancasler commentedI have access to phpmyadmin, will give this a look
Comment #8
bryancasler commentedShould I just delete this row?
http://awesomescreenshot.com/0bd7odh52
Comment #9
AgaPe commentedno no do not delete it :) at the begining of the line you have the edit button (a pencil or sth like that), click it and edit the field "active" from 0 to 1
Comment #10
bryancasler commentedThanks, I made that one change and I got the following error when looking at the node's "Manage Fields" page.
I then thought maybe I should try re-enabling the media module before doing this. So I reset the value back to 0 and enabled the Media module.
Then the following error was spit out while the module was being enabled
The media module looked to have been successfully enabled so I went back into PHPMyAdmin and changed the value back to 1.
Now I get no errors! Thanks for everything.
Comment #11
AgaPe commentedGood its solved. :)
Comment #12
bennash commentedI had the same problem, after downgrading and then upgrading the media module. The fix suggested above worked great for me too. Thanks.
Comment #13
JacobSingh commentedIs this a dupe of
#970696: Disabling and re-enabling media module throws exceptions, leaves website in unusable state.?
Steps to reproduce on latest dev version?
Comment #14
dave reidComment #15
pehohlva@gmail.com commentedI having successful create media field on my migrate typo3 module
but if I migrate 10 image to this field ('cardinality' => 10,) only first (first on array list) item is visible and 10 item go to media browser on dir
& i must select from media browser by hand...