How could i edit cck fields by this module? or are there any other solutions?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

infojunkie’s picture

You need to write an action (in your own module) that exposes a form to capture the new value from the user. VBO will automatically detect that action and you can enable it in the view settings. Refer to taxonomy.action.inc for an example.

negro12’s picture

Get it, thanks!

infojunkie’s picture

Status: Active » Fixed
dww’s picture

I haven't used it, but someone recently pointed me to http://drupal.org/project/editablefields for this sort of thing...

marcus_clements’s picture

Did you write a an action to edit a cck field? If so if you can post it here as an example if would be much appreciated

TIA

marcus

mitchell’s picture

Starbow may have you covered on this: http://www.starbowconsulting.com/node/116

You could also take a look at Field Actions.

marcus_clements’s picture

I had a look at VBO but it seemed designed to perform the same action on a set of nodes defined by the view. For example: unpublish all.
But to provide an edit drop down for each node in a list in order to change the value of a cck field?
How will field actions help here?

dww’s picture

@rayvaughn: http://drupal.org/project/editablefields is supposed to do that.

marcus_clements’s picture

Yes but its Ajax only and the javascript falls over with 30 nodes in a list. I've posted a bug report. Thanks for the help though... I realise now that VBO is not intended to resolve this need.

infojunkie’s picture

Status: Fixed » Closed (fixed)
stacysimpson’s picture

Did you write an action to mass update CCK fields, which hooks into VBO. I would appreciate if you could share. Thanks!

infojunkie’s picture

Assigned: Unassigned » infojunkie
Category: support » feature
Status: Closed (fixed) » Active

FYI, the fieldactions module only exposes the following actions:
* Change node author based on a user reference field (fieldactions_assign_owner_to_userreference_action)
* Send email to a user reference field (fieldactions_send_email_to_userreference_action)
* Send email to the author of the node selected in the node reference field (fieldactions_send_email_to_nodereference_action)
* Send email to the creator of the node (fieldactions_send_email_to_owner_action)
* Send email to the value of an email widget field (fieldactions_send_email_to_email_action)
which is not what is sought in this issue.

Also, editablefields is not suitable because it allows to change each field *per row* which is not what's required either.

So what's needed is a new action that does the following:
* Expose a config form that allows to choose one or more fields from a specified content type, and to let the user specify values for each chosen field.
* Apply the chosen values to the corresponding fields of each node that's passed to it

Through VBO, one would then be able to select a bunch of nodes and set some fields to a desired value in *all selected nodes*.

stacysimpson’s picture

kratib, that's exactly what we need. The 'Action Views' module, http://drupal.org/project/action_view, provided a similar capability in D5; however, it hasn't been ported to D6. The Bulk View Operations or CCK would seem like the logical places to incorporate the feature.

fyi...I opened a separate feature request against CCK, http://drupal.org/node/386146, as I didn't know if this thread would be re-opened.

We are willing to help test or whatever.

infojunkie’s picture

Version: 6.x-1.3 » 6.x-1.x-dev
Status: Active » Needs review

The latest VBO dev release (which will be available 12 hours from now) contains a new action called "Modify node fields" that implements the spec above. It's still pretty rough around the edges but I was able to modify field values with it. I'll try to add the standard, non-CCK fields but I'm still not sure how.

Please try it and send your feedback on this thread (until it's officially released). Specifically, I'd be very grateful if you could try out different types of CCK fields and notify me of their behaviour. Thanks!

stacysimpson’s picture

I installed the dev release dated '2009-Mar-10'.

Problems:
- When attempting to edit a text field, it didn't work. Error message:

    * warning: Invalid argument supplied for foreach() in /media/storage/www/drupal6/sites/all/modules/views_bulk_operations/fields.action.inc on line 97.
    * You must select at least one field to modify.

- Also, noticed the allowed values for a text - select list widget do not pre-populate. Just blank.

So, I wasn't able to do too much.

Feature Requests / Questions:
- No option in the table to "select all" displayed nodes.
- Is the module configured to create new node revisions when updating? If so, our site is configured to require a node revision log message when creating new revisions. Can this be exposed as well?
- Usually, we only need to update a particular field at one time. How difficult is it to only display certain fields and manage this on a view basis?
- All the PHP code text fields display without any header / description information, so it's hard to tell which one goes with which field.

infojunkie’s picture

Thanks for your feedback. I'll work on the issues you reported.

Concerning the single-field update, I think I will postpone this feature because it will require to have per-action, per-view administration screens which is not built in the actions framework of Drupal currently.

infojunkie’s picture

Hi stacysimpson, I committed some changes to the fields action, and I'd appreciate if you could take a look at it. Here's what you should find:

* The select all checkbox is there.
* The PHP code area is now highlighted with its corresponding field. I hope that's enough in terms of visual clue.
* I successfully tested against a text field with select widget, as well as node reference and user reference.

If the text field still doesn't work, please export your CCK type and paste it here. There are surely some setting combinations that I didn't try.

Thanks!

infojunkie’s picture

The latest dev release contains support for common non-CCK node fields such as title, body, log, etc.

stacysimpson’s picture

FileSize
11.38 KB

kratib, I see the 'select-all' checkbox and the non-CCK node fields are displaying now. However, something must be different in our installations because I'm still not seeing enough information on the view itself to perform a valid test.

Take the built-in 'Story' content type and attached screenshot for example.

There are 2 blank check boxes and empty text fields displayed above an 'Input Format' collapsible section. Below it are 9 blank check boxes and empty text fields. The top section seems to be correlated to the number of CCK fields that are part of the content type; however, I cannot tell what-is-what due to the lack of a field label.

I went ahead and entered random text in each of the fields and received the following error, "Parse error: syntax error, unexpected $end in /media/storage/www/drupal6/sites/all/modules/views_bulk_operations/fields.action.inc(142) : eval()'d code on line 1". Again, I have no idea what I was attempting to modify.

stacysimpson’s picture

kratib, well, I've finally carved out some time to dig deeper into the missing label issue. Unfortunately, I don't know PHP that well and don't see anything obvious. I tried comparing the non-CCK fields with the CCK field, but the form-related PHP trickeration has me lost. Any help is appreciated!

infojunkie’s picture

Given your screenshot, I would say that the form action theme function is not being picked up. Please try to flush your Drupal caches and check again.

patchak’s picture

Hey there I installed the latest dev version of this module, to try and change the values of some cck fields, but i get this error :

Fatal error: Unsupported operand types in /home/blogsurf/sites/intranet/sites/all/modules/views_bulk_operations/fields.action.inc on line 51

which is : $form[$field['field_name']] += array('#weight' => $weight++, '#prefix' => '

', '#suffix' => '

');

so not sure what is wrong here...

Any ideas?

Thanks,
Patchak

infojunkie’s picture

@patchak: thanks for your report.
* Are you running this action as the site admin or as another user?
* Can you please insert a var_dump($field['field_name']); just before that line? I'd like to know which field is causing the error.

Thanks!

gionnibgud’s picture

Hi I'm having the same Unsupported operand as patchak when selecting the change cck field action.
I've downloaded the latest VBO dev. D6.10. Updated releases of CCK and Views.
Here's my vardump

string(15) "field_tipologia"
string(17) "field_frif_biblio"
string(5) "title"
string(6) "format"
and then the fatal error.

Thanks!

infojunkie’s picture

@gionnibgud: Thanks for your report. Are you running this action as admin or another user?

infojunkie’s picture

I committed a fix in fields.action.inc to make inclusion of non-CCK fields more robust. Please try it (download the dev tar.gz package 12 hours from now or get from CVS directly) and let me know if it solves the "unsupported operand types" error.

vanderlip’s picture

FileSize
48.04 KB

Sorry, I have probably missed something. After installing 6.X-1.x -dev from April 2 2009, the action "Modify node fields" seems to be missing from the list of option when selecting the Style gear. See attached. In addition, on the modules page of my site, the version number shows 6.x-1.3.

Thanks for any guidance.

infojunkie’s picture

@vanderlip: You are probably using an old version unwittingly. Please make sure that your modules folder(s) don't contain 2 VBO folders.

vanderlip’s picture

Absolutely right. I somehow got a version of the module into the directory of another module. Sorry, for the fire drill. Thanks!

stacysimpson’s picture

kratib, I installed the latest dev build from 4/7/2009. After clearing the views cache and page cache, I now see new form items listed for the CCK fields; however, I still see that large list of blank checkbox and text entry form items. The number of these blank (no-label) form entries still seems to be correlated with the number of fields associated with the content type.

1st attempt:
I tried to enter new content in the form items which now appear with appropriate labels (after flushing caches). However, when attempting to execute the action, I get a message that says, "You must select at least one field to modify."

2nd attempt:
I randomly tried to enable a few of (blank) checkboxes and enter text in the text fields without labels.

After confirming, I received the following error message:

Parse error: syntax error, unexpected $end in /media/storage/www/drupal6/sites/all/modules/views_bulk_operations/fields.action.inc(142) : eval()'d code on line 1

After navigating back to the view, I received the following message:

warning: Invalid argument supplied for foreach() in /media/storage/www/drupal6/sites/all/modules/link/link.module on line 200.

Looks like that the issue must be in the ordering / organization of the form elements. My attempt #2 must have tried to modify the values for one of my custom CCK fields.

I tried defaulting back to the default Drupal theme, disabling page caching, disabling view caching and still see the series of checkboxes and text form fields with no labels.

Is there any other information I can provide you on the form element / entities alignment and/or organization issue?

infojunkie’s picture

@stacy: It still seems that the code doesn't reach the action form theming function. Can you please insert a couple of var_dumps to make sure? One at views_bulk_operations.module line 358: var_dump($function);. The second at fields.action.inc line 88: var_dump($field_name);. What do you get? Thanks for your patience!

stacysimpson’s picture

FileSize
2.85 KB

Ah ha, found the culprit. There is a 'Merge single action's form with node selection view' setting when creating views that causes this problem. By deselecting, I see the form elements organized now as a table (on a separate page, which is fine).

screenshot of view option

I don't know if you can disable this or whatever, but toggle this option on to see what I was seeing. We will proceed to do a more thorough test with our CCK fields...it seems to be working much better now! Thanks again.

infojunkie’s picture

Thanks for sorting this out! I'll check out the mess created by merging the form.

stacysimpson’s picture

FileSize
30.57 KB

kratib, excellent work here! I did not mess around with the 'PHP Code' option; only, static field content.

Feedback below:
1. Looks like there is a small issue with the 'FileField' module. When a CCK field of this type is associated with a content type, the following warning message is displayed on the confirmation screen.

warning: Invalid argument supplied for foreach() in /media/storage/www/drupal6/sites/all/modules/filefield/filefield_widget.inc on line 472.

However, VBO does actually set the FileField CCK field to the specified value.

2. Changing the node author field doesn't seem to work. I tried with and without creating new revisions, etc. The "new author" also has admin rights, so I don't think it's a permissions thing. No errors or warnings were displayed or logged.

3. Weirdness with Body field (see screenshot). The WYSIWYG editor for the body field shows up in the 'Code' column. The 'input format' is a separate row with another text field. You might want to look at that a bit.

4. You are probably tired of hearing from me on this subject; however, another feature request for you to ponder. With these changes, VBO can overwrite (CCK and non-CCK) fields with specified information. Which is awesome. However, when using multi-select fields in our environment, we often only want to add or remove particular selections based on some filter criteria. (Similar to Drupal's built-in capabilities to assign or remove new taxonomy terms.)

Either way, this will be a big help to us.

infojunkie’s picture

@stacy: glad it's finally working. Thanks a lot for hanging in there! I'll take a look at the issues you encountered. Can you please explain #4 again? I'm afraid I didn't get what you're trying to achieve. An example might help :-)

stacysimpson’s picture

FileSize
13.11 KB

kratib, Re: Feature Request Q. The current implementation allows contributors to blast or overwrite fields without regards for the current value of those fields. This is a valued and needed feature, even for multi-select fields.

However, on an on-going basis, many of our mass update requirements for multi-select CCK fields is to add and/or remove only a single selection without modifying the existing selected values.

There are two built-in examples of this in Drupal and one theoretical example below:
1. Add or Removing Taxonomy values in the content management interface. (see screenshot)
2. Add or Remove roles in the built-in user management interface. (see screenshot)
3. Completely made up scenario below.

Complete range of possible values: Apples, Bananas, Oranges, Strawberries

Before:
Node #1 - Likes fruit:
 - Apples
 - Oranges

Node #2 - Likes fruit:
 - Apples
 - Bananas

I want to add 'Strawberries' as a selection to both of these nodes, but leave the other values intact.

Node #1 - Likes which fruit:
 - Apples
 - Oranges
 - Strawberries

Node #2 - Likes which fruit:
 - Apples
 - Bananas
 - Strawberries

This will be difficult to do with the current implementation because I can only overwrite all the selected values for the multi-select field.

Seems like the 'Action View' module had a configuration option within the view to merge or overwrite selected values for multi-select fields, but I don't remember exactly how it worked. Unfortunately, we've already whacked our D5 installation.

As a non-SME, I suppose you could add 2 new, distinct VBO actions for adding or removing values for multi-select fields only. When saving the modified value(s), merge the new selections (either adding or removing) with the field's existing values.

Hope this makes sense.

infojunkie’s picture

Re: Multiple values: got it now. I'll think of a clean way to add it to the field action.

Concerning the other issues:
1) Filefield warning: that's a tricky issue that will require significant work. Currently, what this warning means is that field validation is not occurring for filefields.
2) Changing the node author: I just committed a fix to resolve that issue.
3) a) Which WYSIWYG editor are you using? FCKEditor 6.x-1.3 did not behave this way.
b) Input format in a separate row: fixing this would require extensive work and I don't think it's worth it. For now, this minor annoyance will remain.

stacysimpson’s picture

kratib, we are actively evaluating other WYSIWYG editors because FCK seems to be a bit buggy (although we currently use FCK in our production environment). The editor we are currently looking at: http://drupal.org/project/wysiwyg. NOTE: The WYSIWYG editor only displays in the 'Code' column for the 'Body' field. It displays appropriately in the 'Field' column for other CCK text fields.?.?

No worries on the 'Input format' quirk.

patchak’s picture

Hey there Kratib :

Sorry for the delay on this issue, I was really busy but now came back to this problem..

As per your comment on no.23 here is the debug I get for my error :

I'm not sure if that helps you or not, but these fields are not all the ones I entered in my view.

string(20) "field_membres_relies" string(25) "field_membre_comite_apres" string(19) "field_statut_membre" string(15) "field_agence_cp" string(9) "field_nom" string(12) "field_prenom" string(15) "field_politesse" string(11) "field_notes" string(11) "field_canal" string(26) "field_contact_projet_relie"

Fatal error: Unsupported operand types in /home/blogsurf/sites/intranet/sites/all/modules/views_bulk_operations/fields.action.inc on line 52

I'm using latest dev build, not sure what would be causing this issue, I do have one custom cck field type in my site, based on nodereference code...

Thanks for any help, I really need this feature to manage a content import that went wrong ;)

Patchak

infojunkie’s picture

@patchak: is field_contact_projet_relie your custom field? If so, can you please post the code for it?

patchak’s picture

FileSize
142 bytes

Hey there, thanks for the answer! Attached is my custom cck field that is based on nodereference field, it just adds a "meta" field to the nodereference so users can leave a comment.

Patchak

Dimm’s picture

For D5 :
The 'Action Views' module, http://drupal.org/project/action_view
Allows you to edit multiple cck fields at once.

+ It need patch:
http://drupal.org/node/244439

mattgilbert’s picture

subscribe

infojunkie’s picture

@patchak: I didn't have time last week to look at your custom field. However, it seems the package you sent contains a zero-byte file. Can you please check and re-upload?

mikeytown2’s picture

Status: Needs review » Needs work

Get the same error

Skipping the fields works...

    if (($field['field_name'] != 'field_referrers') && ($field['field_name'] != 'field_testimonials')  && ($field['field_name'] != 'field_dimensions')) {

http://drupal.org/project/nodereferrer
http://drupal.org/project/computed_field

Computed Field

<?php
//Set Temp Variables
$temp_length_ft = '';
$temp_length_in = '';
$temp_length_in_fraction = '';
$temp_width_ft = '';
$temp_width_in = '';
$temp_width_in_fraction = '';
$temp_height_ft = '';
$temp_height_in = '';
$temp_height_in_fraction = '';
$temp_lwh_array = array();

//Compute length
if ($node->field_length[0]['value'] != '') {
	$temp_length_ft = $node->field_length[0]['value']  . ''; 
	if ($node->field_length_inches_fraction[0]['value'] != '') {
		$temp_length_in_fraction = '&nbsp;' . $node->field_length_inches_fraction[0]['value']  . '&quot;';
		if ($node->field_length_inches[0]['value'] != '') {
			$temp_length_in = '&ndash;' . $node->field_length_inches[0]['value'];
		}
	}
	else if ($node->field_length_inches[0]['value'] != '') {
		$temp_length_in = '&ndash;' . $node->field_length_inches[0]['value']  . '&quot;';
	}
	else {
		//$temp_length_in = '0&quot;';
	}
	$temp_lwh_array[] = 'L:' . $temp_length_ft . $temp_length_in . $temp_length_in_fraction;
}

//Compute width
if ($node->field_width[0]['value'] != '') {
	$temp_width_ft = $node->field_width[0]['value']  . ''; 
	if ($node->field_width_inches_fraction[0]['value'] != '') {
		$temp_width_in_fraction = '&nbsp;' . $node->field_width_inches_fraction[0]['value']  . '&quot;';
		if ($node->field_width_inches[0]['value'] != '') {
			$temp_width_in = '&ndash;' . $node->field_width_inches[0]['value'];
		}
	}
	else if ($node->field_width_inches[0]['value'] != '') {
		$temp_width_in = '&ndash;' . $node->field_width_inches[0]['value']  . '&quot;';
	}
	else {
		//$temp_width_in = '0&quot;';
	}
	$temp_lwh_array[] = 'W:' . $temp_width_ft . $temp_width_in . $temp_width_in_fraction;
}

//Compute height
if ($node->field_height[0]['value'] != '') {
	$temp_height_ft = $node->field_height[0]['value']  . ''; 
	if ($node->field_height_inches_fraction[0]['value'] != '') {
		$temp_height_in_fraction = '&nbsp;' . $node->field_height_inches_fraction[0]['value']  . '&quot;';
		if ($node->field_height_inches[0]['value'] != '') {
			$temp_height_in = '&ndash;' . $node->field_height_inches[0]['value'];
		}
	}
	else if ($node->field_height_inches[0]['value'] != '') {
		$temp_height_in = '&ndash;' . $node->field_height_inches[0]['value']  . '&quot;';
		
	}
	else {
		$temp_height_in = '&ndash;'.'0&quot;';
	}
	$temp_lwh_array[] = 'H:' . $temp_height_ft . $temp_height_in . $temp_height_in_fraction;
}

$node_field[0]['value'] = implode('&nbsp;x&nbsp;', $temp_lwh_array);
?>
doc2@drupalfr.org’s picture

Oh yes, please add this feature! And backport for d5...
We are a few d5ers who badly need this feature since editablefields doesn't seem regularly maintained...

In my case, editablefields doesn't work anymore for date v.2. It had been working with date v.1 but having it hacked for bulk update...
Quite a stake to get a CCK bulk update feature in VBO! But what a feature!

Best wishes towards the development of this feature. Kind regards, Arsène

infojunkie’s picture

@doc2: The action "Modify node fields" is already functional on D6, but I doubt I'll have the time/energy to backport it to D5. I can help someone else to do it though...

Aren Cambre’s picture

This issue has wandered a lot, so I am not clear it's addressing the essential need of bulk editing CCK fields with VBO. Also, I am having a problem with the PHP code way of editing, which appears to not be the focus of this issue. I have therefore opened #516560: Doesn't bulk edit CCK fields with PHP to document my problem.

infojunkie’s picture

Status: Needs work » Fixed

Marking this feature a fixed. Please open separate issues for specific problems you might find.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Dret’s picture

Component: Code » Core

How is possible to create an action to perform changing values (and only this kind of action; not add, delete or other) for a single specific CCK Fields but don't allow changing of all others fields?

Thanks Bye!

infojunkie’s picture

@Dret: On the view's admin screen, edit the "Bulk Operations" settings (gear icon). Near the bottom, you will find a section called "Modify node fields". Open it and select the desired fields in the "Display fields" area.

Dret’s picture

Thanks for reply!

I followed your suggestion but when I click on the gear Icon, the "Display Fields" Area doesen't appear. At the botton of the option list there's only a list whit all operations (called "Selected operations:").

But nothing to choose "which" fields have to be avaiable on changing option.

Ideas...??

Bye!

infojunkie’s picture

Version: 6.x-1.x-dev » 6.x-1.9

Are you using the latest version?

Dret’s picture

Probably is old... 6.x-1.8!

I'll try tomorrow with the latest one to confirm or not the problem.

Thanks!

Dret’s picture

Confirmed!

The version was too old!

Upgrading to last one the menu correctly apper!

Thanks a lot!
Bye!

chrispeat’s picture

I cant get 'Modify node fields' to show an input field or action for changing a set of nodes values. Am I missing something?

I am expecting to select this, and then have an input field that allows me to enter a value to change for all the nodes selected, or alternatively selct and action and then enter a value, like the change author action.

I would really appreciate any help on this, I think I am really close to figuring this out but have been stumped for days?

Thanks,

Chris :)

infojunkie’s picture

@chrispeat: please describe the steps that you do to reproduce your problem. Are you using the latest VBO?

chrispeat’s picture

Hi infojunkie,

I have to be honest, I spent a morning looking at this problem, and not realising that you have to tick the action box and select the fields at the bottom so my mistake entirely but I hope that this reply helps others too. The solution is amazing, and something that I thought I would spend a long time trying to figure out so am really happy on a Friday afternoon!

Thanks for the help, and thanks for the great solution everyone!

Chris

infojunkie’s picture

@chrispeat: glad to hear it.

benone’s picture

Ok, so I have latest VBO (6.x-1.9) and I select nodes then choose 'Modify node fields' , I have fields so I change select list field value and the rest of field I dont touch, click Next and I have error msg: 'You must select at least one field to modify.'
Where I must select them ?
There is no select fields , just clean CCK fields which are the part of nodes I selected before.

What am I missing ?

infojunkie’s picture

@benone: In the VBO style plugin settings, you need to select the field(s) that should be editable. Do that first and then try to modify node fields again. Do you see the selected fields?

benone’s picture

I see checkboxes , but they are below the fields and without any labels. I had to check page source to see their values.
What can cause hiding labels and displaying checkboxes below ?
Thanks for your re.

infojunkie’s picture

That was a bug: #767358: Theme functions from .inc files are missing from registry. Please try the latest dev (as of today) and let me know.

benone’s picture

Tried. Now it looks properly and works fine.
I don't know if you already know... your module rocks!
THX

kbk’s picture

sub

verres’s picture

Title: How to bulk edit cck fields? » Where is the 'modify node fields' action located

I'm wondering where the code for the 'modify node fields' is located? I'd like to look at the code itself. Specifically, I'm trying to understand what functions get called so that 'unlimited node-reference fields' get posted correctly in View Bulk Operation. I am trying to decide if I need/can write a module specifically for updating a node-reference field (with unlimited numbers) and seeing the VBO action code would help me understand. Thanks

infojunkie’s picture

Title: Where is the 'modify node fields' action located » How to bulk edit cck fields?

@verres: please don't change the title of an issue just to ask a question - it's enough to ask it in the comment. The file you need is fields.action.inc.

iantresman’s picture

The Slickgrid module works for me, displaying a Views-generated grid of CCK fields, double clicking on which, lets you edit fields in situ.

joachim’s picture

Version: 6.x-1.9 » 7.x-3.x-dev
Status: Closed (fixed) » Active

Is this feature possible in D7?

bojanz’s picture

Version: 7.x-3.x-dev » 6.x-1.9
Status: Active » Closed (fixed)