0

I have created a select list field in my Entity Form.

Select List : none||none and AM||AM and PM||PM

In my computed field, I want to know what did the user chose by using IF STATEMENT

example:

if($halfday == 'AM')
{
//action
}

I tried to use array_pop (example code :

$halfday = array_pop(field_get_items($entity_type,$entity,'field_halfday'));)

but it does not work for me. What PHP code should I use? Any suggestions?

1 Answer 1

1

Write the following code under Computed Code (PHP) texarea in computed filed settings

$calc =  $entity-> field_sample['und'][0]['value'];

if($calc == 'AM')
{
 //action
$entity_field[0]['value'] = 'After Meridian';
}

elseif($calc == 'PM')
{
//action
$entity_field[0]['value'] = 'Prime Meridian';
}

This is a sample tested code which prints the selected item at output of computed field.

Note: replace filed_sample with your select list field machine name.

0

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.