0

I'm making a custom payment module for Commerce that references a Credit Card entity. I have the entity reference form field in there and working but I cannot pass on the selected Credit Card entity to the "message" field. If I could just print whatever the title of the entity reference they select, that would work, or if I could access one of the 5 fields in the entity itself, that would be ideal.

Here is my module: http://pastebin.com/373WDAzA and this is the error message I get:

Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain() (line 1559 of C:\xampp\htdocs\includes\bootstrap.inc).

2 Answers 2

0

Problem solved thanks to the #drupal-support IRC room. I did a dpm($pane_values) and saw that it was retrieving what I wanted, the Entity Label. I just changed the code so that it's

$pane_values['card_on_file'][0]['entity_label'] 

and presto!

0
$form['card_on_file' ] = array(
  '#type' => 'entityreference',
  '#title' => t ('Credit Card'),
  '#era_entity_type' => 'node', // Mandatory 
  '#era_bundles' => array(credit_card ), // Optional (Any bundle by default).
  '#era_cardinality' => 5, // Optional (1 By default).
  '#required' => TRUE,
) ;

the warning corresponds to this replace this code:

'#era_bundles' => array(credit_card ), // Optional (Any bundle by default).

with

'#era_bundles' => array('credit_card'),

Link: https://api.drupal.org/api/drupal/includes!common.inc/function/entity_load/7

$ids = array();

get $ids from $form_state['values'] of submit handler function.

use entity_load('credit_card', $ids);

3
  • Hi harshal, I get this error when I remove the array () from the #era_bundles -> Warning: in_array() expects parameter 2 to be array, string given in entityreference_autocomplete_validate_entityreference()
    – Ash
    Jan 27, 2014 at 17:40
  • check the edited answer
    – harshal
    Jan 28, 2014 at 3:44
  • I get the same error with the edit. Just to be clear, all I've done is add '' around credit_card. I have not changed anything else in the module.
    – Ash
    Jan 28, 2014 at 13:22

Your Answer

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

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