Skip to content

Instantly share code, notes, and snippets.

@wimleers
Created April 10, 2013 12:57
Show Gist options
  • Save wimleers/5354368 to your computer and use it in GitHub Desktop.
Save wimleers/5354368 to your computer and use it in GitHub Desktop.
print '<hr>';
// Node -> EntityFormController
$entity = entity_load('node', 1);
$entity = $entity->getBCEntity();
var_dump($entity->getTranslation('und', FALSE)->get('field_tags')->getValue());
$form = array();
$form_state = array();
$options = array(
'field_name' => 'field_tags'
);
xdebug_break();
field_attach_form($entity, $form, $form_state, 'und', $options);
drupal_prepare_form('form-id-here', $form, $form_state);
drupal_process_form('form-id-here', $form, $form_state);
var_dump($form['field_tags']['und']['#default_value']);
var_dump($form['field_tags']['und']['#value']);
print drupal_render($form);
print '<hr>';
// CustomBlock -> EntityFormControllerNG
$entity = entity_load('custom_block', 1);
$entity = $entity->getBCEntity();
var_dump($entity->getTranslation('und', FALSE)->get('block_body')->getValue());
$form = array();
$form_state = array();
$options = array(
'field_name' => 'block_body'
);
field_attach_form($entity, $form, $form_state, 'und', $options);
drupal_prepare_form('form-id-here', $form, $form_state);
drupal_process_form('form-id-here', $form, $form_state);
var_dump($form['block_body']['und'][0]['value']['#default_value']);
var_dump($form['block_body']['und'][0]['value']['#value']);
print drupal_render($form);
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment