2

I have a content type cFoo. This content type has e.g 10 fields.

I want:

  1. user has page node/cfooxx/edit/screen1 and sees only fields 1,2,3,4,5
  2. user has page node/cfooxx/edit/screen2 and sees only fields 6,7,8
  3. user has no access to fields 9,10

I did a lot of reseach on this but it is not clear for me.

  • how to get the splitting of the standaard node/xx/edit url to edit/screen1 and edit/screen2?

  • On the front I use display suite so I can manage a display. Is there a module which can do this with edit forms as well?

  • If I use css, still fields of screen1 are processed in background of screen2 and the other way around. I do not want this because of possible errors in form validation. But suppose i need to do this... then the /node/cFooxx/edit url containts fields 1/2/3/4/5/6/7/8. So how to decide which css to apply when entering /node/cFooxx/edit?

  • If I use hook_form_alter how to identify screen1 and screen2?

  • Point 3 I can solve with field permissions module

1
  • you can use form alter based on the argument, something like arg(3) == 'screen1', have you tried that ? i think in your case argument array arg() will help you
    – Sanjay
    Jul 8, 2016 at 11:49

2 Answers 2

1

You could use different modes on the two routes. Go to /admin/structure/types/manage/fooxx/form-display and there you can configure which fields you want see on which mode.

You can add new modes here: /admin/structure/display-modes

Note: While Drupal 8 core already comes with "form modes", in Drupal 7 you need to install the flexiform module.

enter image description here

4
  • for my understanding these modus can only be used for displaying (viewing) not for node form editing. Is that correct?
    – Justme
    Jul 7, 2016 at 16:57
  • No, for example you can have a 'default' form for nodes and a 'settings' form.
    – Maouna
    Jul 7, 2016 at 17:33
  • @Justme updated this answer, since you originally didn't mention your Drupal version, Maouna assumed you were on D8.
    – No Sssweat
    Jul 8, 2016 at 4:23
  • Within D7 I installed Display Suite but still I do not understand how to split the EDIT screens. I do understand how to split the form DISPLAY screens. Any suggestion?
    – Justme
    Aug 10, 2016 at 16:04
0

@Sanjay's solution is the only way I can think of. I had done the similar thing before for a similar situation as question stated.

I would separate the logic into 2 different functions.

function mymodule_form_cfooxx_node_form_alter(&$form, &$form_state) {

  switch (arg(3) {
    case "screen1":
      _mymodule_form_screen_1($form, $form_state);
      break;
    case "screen2":
      _mymodule_form_screen_2($form, $form_state);
  }

}

function _mymodule_form_screen_1(&$form, &$form_state) {
  ...
}

function _mymodule_form_screen_2(&$form, &$form_state) {
  ...
}
1
  • Suppose I do this. How to get the fields display in scenario 2. So how to display only field 5 6 7?
    – Justme
    Aug 10, 2016 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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