0

I'm using the module EntityForm to create a couple of different forms.

Each form should be attached to a different content type as an entity reference field.

I can create an entity reference field that shows a select list of "EntityForm Type" from which the user can choose when creating content. I would like to set a default value however (and will hide the field so it can't be changed), since there shouldn't be choice as it's always the same kind of form that needs to be attached.

I know this is possible with nodes by loading a specific node, but in this case they're entityform types and not nodes.

0

I've found a way, but it might not be the best way. I remove all the other options from the select list so the one I want is the only one left. (What is strange, is that in some content types I can set a default value for the entity reference and in some I cannot, but this worked anyway)

if ($form_id == 'inschrijvingsformulier_testdag_p_node_form'){

    $form['field_inschrijvingsformulier_tes']['und']['#options']=array(1 => 'inschrijvingsformulier testdag',);
    $form['field_inschrijvingsformulier_tes']["#attributes"]['class'][] = 'element-invisible';
}

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.