Seems like this feature request would already exist.. Don't know if I trust the brand new issue search.

Right now if I create a field, say email, and i want it required on one content type and not the other, this is not something i can do. Is there a systematic limitation on having this ?

Comments

infojunkie’s picture

Subscribe.

AFAICT, the 'required' attribute is currently stored in table content_node_field, not content_node_field_instance. That's why it applies to all instances of that field. Whether it *needs* to be stored there or just happened to be needs more investigation.

karens’s picture

Status: Active » Closed (works as designed)

This would be a structural change, which isn't going to happen for the D6 version. We are already deep into D7 fields in core, no one has time or interest in making structural changes to the D6 version at this point.

infojunkie’s picture

Version: 6.x-2.1 » 7.x-2.x-dev
Status: Closed (works as designed) » Active

So can we request that change for D7?

karens’s picture

Version: 7.x-2.x-dev » 6.x-2.x-dev
Status: Active » Closed (won't fix)

Fields are in core for D7, so it isn't a CCK issue. And pretty much everything about fields is different for D7, but this is one of the changes that has already been made.

yan’s picture

This would be a structural change, which isn't going to happen for the D6 version.

But it was like that in 5.x, right? I don't see the point in not allowing the "required" setting on a content type basis. So now I need to create the exact same field twice just to have a different field setting on every node type?

karens’s picture

No, it worked the same in D5 and D6 (and D4.7 for that matter), D7 is where things will change. And yes, you have always had to create different fields if you want different settings.

betoaveiga’s picture

I don't know if i'm wrong but... Using hook_form_alter and the #after_build function it's possible to achieve this behavior.

Your field should be set as non mandatory, and using hook_form_alter with an #after_build function you can change this value on the fly for specific node types or situations (I need this only when the widget was option).

The code of what I'm doing right now is below. Until know everything seems to work fine. If you have devel installed you can remove the comments in the kpr function to see the structure of the form.

  function powstuff_form_alter(&$form, $form_state, $form_id) {
    // Afectar sólo a los formularios de ingreso de nodos
    if (strpos($form_id,'node_form')!==FALSE) {      
      // Cuando el provincia tenga widget de option button hacemos los cambios 
      if (isset($form['field_provincia']['#type']) &&
         ($form['field_provincia']['#type']=='optionwidgets_buttons')) {
            // Llamo al after bluid porque ahí es cuando se carga la información de los fields
            $form['field_provincia']['#required']=1;
            $form['#after_build'][]='powstuff_provincia_option_nd';
            // kpr($form);
      } 
    }
  }

  function powstuff_provincia_option_nd ($form, &$form_state) {
    // Quito la opción de no tener opcion :)
    unset($form['field_provincia']['value']['']);
    // Hago que el campo sea obligatorio
    //kpr($form['field_provincia']);
    $form['field_provincia']['value']['#required']=1;
    return $form;
  }

PD: This thread is old... but this may help somebody... like me :)