It works, but firebug throws an error: button has no properties...
redirectFormButton("http://localhost/my_site/?q=imagefield/js", undefined, Object button=#field-picture3-attach-button).
Also make mess with other modules js code (paypalnode). I have 4 single value imagefields and tried to hide 2 of them for some roles when creating node but always get same error no matter what I do. Tried with 'cck_field_perms', custom code... but always the same. I suppose it's because of upload button in imagefield, if you have any idea how to solve this, please help.
Thank you.

Comments

infojunkie’s picture

Assigned: Unassigned » infojunkie

Hello,

I was unable to reproduce your problem. I installed imagefield.module and added 2 image fields to my test content type. For some workflow state I made one of these fields un-editable, but both the node view and node edit worked without Firebug complaining. I then made the same image field invisible, and got the same result.

Can you plz describe a step-by-step scenario that reproduces the problem, including the needed modules?

Thanks for your help.

baja_tz’s picture

Thanks for your reply. I made 4 single value imagefields, first 2 visible for all, second 2 visible just for certain role, just for creating node not for viewing. When creating content with role which is not suppose to post 4 pictures but only 2, i've got that error. I suppose this part of code in imagefield is still trying to execute:
$form[$fieldname .'-attach-url'] = array('#type' => 'hidden', '#value' => url('imagefield/js', NULL, NULL, TRUE), '#attributes' => array('class' => 'upload'));
I made some workaround and added condition if (imagefield_extra_pics($field, $node )) { before preceding part of code. Created new field (check box) in imagefield, called extra_picture, to be able to assign extra picture property to imagefield while puting it in content type. Than made new user_access('post extra pictures') and this function:

function imagefield_extra_pics($field, $node) {
$access = true;
 
if ($field['widget']['extra_picture'] == 1) {
    if ($node->nid) { // just editing, not new node
	$price = paypalnode_calculate_fee($node->nid);
        if ($price == 0) {
          $access = false;
        }
        elseif ($price > 0) {
	          $access = TRUE;
        }
        return $access;
        break;
    }
    elseif (!($node->nid) && !user_access('post extra pictures')) { // creating new node
     $access = false;      
    }

  }
  return $access;
}

And finally:

function _imagefield_widget_form($node, $field, &$items) {
...
$form[$fieldname] = array(
...
'#access' => imagefield_extra_pics($field, $node),
...
}

Eh, for now it works, but i had to change some things in imagefield module which i don't like to do. I'm sure that there is much easier solution but i'm new in Drupal so this is the best I could do. I hope that it helped you to get some idea where the problem is. Modules (last versions):
drupal 5.2
cck
imagefield
paypalnode
Workflow Fields or cck_field_perms
lightbox v2 5.x-2.1

infojunkie’s picture

Status: Active » Closed (fixed)

I changed the approach to hiding fields since then, so I'm closing this until the issue re-surfaces.