As I understand it, if I want to create a "preprocess field" programmatically I can do something like this:

function mytheme_preprocess_node(&$vars) {
  $vars['myfield']="Hello, world!";
}

function mytheme_ds_fields_info($entity_type) {
  $fields = array();
  $fields['myfield'] = array(
    'title' => t('My own preprocess field'),
    'field_type' => DS_FIELD_TYPE_PREPROCESS,
  );
  return array('node' => $fields);
}

But if I want to add a preprocess via the GUI where do I specify the variable name (set in some preprocess function somewhere) that should be used to populate the field. When I go to add a field, I am simply asked what entity type the field should be available to. Am I missing something here??
Recipe | DinnerTool

I suspect I'm just missing something obvious here...
Thanks for your help!!

Comments

swentel’s picture

There is some info at the top of the form on the preprocess field: 'The machine name of this field must reflect the key in the variables, e.g. "submitted".'

I guess it's a bit confusing here. The machine key of that field must be the key in the preprocess variables. Maybe I should see if I can change the label of the machine field to something more clearer here and not hide it by default.

bleen’s picture

Aha ... now I get it.

Yeah, I think changing the label might help ... it also may help to have some text on the "manage display" screen where I thought the "setting" button should be that just indicates, "The preprocess variable name is set to FOO" (or whatever)

swentel’s picture

Status: Active » Closed (works as designed)

I had some more thoughts about this, but the problem is that a part of the form is shared by all fields, so I currently left it this way, but I added more help text on the preprocess field at the top. Hope it's clear enough now. Also, adding info on Field UI isn't that simple since I would need to implement a hook for this to just add info, but the icon on the right would do nothing. Hoping to make this a bit clearer in the #1242620: Do not show limit textfield on formatter settings edit issue.

swentel’s picture

Issue summary: View changes

Revamped issue summary.