1

I am trying to build a questionnaire that simply replaces (alters) the label of a list-field.

I´m doing so by replacing a token from views (embed) and using a hook_alter_form function in an separate module.

Question: How can I save that value and write it to the database? I´m using an Entity form and a list-field.

This is the snippet I´m struggling with:

function question_to_label_node_presave($node) {
  if ($node->type == 'page') {
    $replaced_text =  token_replace($node->field_question['und'][0]['value']);
    $node->field_question['und'][0]['value'] = $replaced_text;
  }
}

Found from here.

I'm currently trying to run this in a custom module but cannot seem to find the right node type for Entity form. I´m using the Devel-module, trying to find the right array value.

  • Hi and welcome to Drupal Answers. Could you please make your question clearer? What is a "select or other"-field? Which entity form? Please share your code. – Wtower Dec 29 '14 at 14:50
0

I´ve solved it by using a token, and placed that token (from a view) in a hidden field in that form - thus saving that value.

The same token generated from views - I used to alter the label for that question with "hook_alter_form".

A kind of non programmatically way of solving the problem.

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.