0

Bit of a weird one....

I'd like to call a node edit form into an overlay but have it only show a file upload (cardinality unlimited) fieldset and the save button

I know I can program the formAPI bits, get the files and save the node myself, but In this (possibly strange) case I'd like to use the existing form.

Obviously can CSS it, but I'd rather have it in PHP.

So far I've set up a loop in a conditionally invoked form alter that finds form elements and then... well, unsetting/hiding them gets them off the screen but then the upload field doesnt work

foreach($form as $key => &$value) {
  if(is_array($value) && isset($value['#type'])) {
    if(  !in_array($value['#type'], array('hidden', 'value')) 
      && !in_array($key, array('field_my_file_field', 'actions'))) {
      unset($form[$key]);
      //or $form[$key]['#type'] = 'hidden';
    }
  }
}

I'm guessing I'm compromising the form array, so it's not working in a callback somewhere.

Any ideas? Or a better suggestion for getting just the field upload fieldset onto a page?

Thanks!

0

You can use Field Permission module to hide all those fields which you don't want to show on node edit or node create form for all user type which you want.

  • Thanks, i forgot about permissions. ive just run my code setting #access = false to achieve the same thing and quickly test, but my form fails validation and is said to be 'out of date' I have a feeling that this will happen with field permissions too but I guess I'll need to give it a go! – joevallender Aug 16 '13 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.