is there a module that can set a value of a field which depends on the value of another field first? I know i can do it via js, but was wondering if something was out there already. conditional field module doesnt work in my case as it dosent set the value depending on the result of another.

example: I am creating a basic page and I have a select box field with the following: white/black/red. when i select red, i want the body to be filled in with 'yes' and if its black i want the body to be filled in with 'no'.

  • "You may draw on anything available to Drupal, including other fields" - how this does not work for you?
    – Mołot
    Jun 20, 2013 at 12:44
  • oh i forgot to mention im talking about the content creation page. Jun 20, 2013 at 12:47
  • No there isn't a module that can arbitrarily set the value of any field based on the contents of another inside an arbitrary, undefined context. Such a thing would be too difficult to implement, and impossible to use effectively. If you need something that complex it's time to pull out the custom modules :)
    – Clive
    Jun 20, 2013 at 12:48
  • And? It works for me on nodes all right. What's your problem again? You want to narrow choices in select Y based on what got selected in field Z? Or what?
    – Mołot
    Jun 20, 2013 at 12:48
  • when something is selected in field Y it should auto input a string into field Z. maybe a quick js snippet would just do it. Jun 20, 2013 at 12:52

4 Answers 4


I guess you need to check on the fields you set as dependant and dependee! In your case the body field should be the dependant and the selection field should be dependee.

Hope it helps!


No other module available apart from conditional field, you need to create your own module with hook form_alter() and use some code like

function wishlist_status_form($form_state) {
$form['status'] = array(
    '#type' => 'textfield',
    '#title' => 'Status',
    '#suffix' => '<div id="my-wrapper"></div>',

$form['ajax-submit'] = array(
    '#type' => 'submit',
    '#ajax' => array(
        'callback' => 'wishlist_status_change',
        'wrapper' => 'my-wrapper',
    '#value' => t('Save'),
return $form;

function wishlist_status_change($form, $form_state) {
    dpm($form_state, 'state callback');
    return 'test';

It might be difficult to change the value of a field without some coding. But it if you just want to store the value based on the value of some other field you should take a look at Computed Field


Perhaps you can use the Rules module and create 2 rules.

  • Event: After saving new content.

  • Condition:

    1. Entity has field. Parameter: Entity: [node], Field: field_colours (Or whatever your field is called.)

    2. Data comparison. Parameter: Data to compare: [node:field-colours], Data value: Red

  • Actions: Set a data value. Parameter: Data: [node:field-body], Value: Yes

You can create a similar rule for 'black'.

Your Answer

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

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