public function NodeInlineEntityFormController::entityForm in Inline Entity Form 7
Overrides EntityInlineEntityFormController::entityForm().
Overrides EntityInlineEntityFormController::entityForm
File
- includes/
node.inline_entity_form.inc, line 38 - Defines the inline entity form controller for Nodes.
Class
- NodeInlineEntityFormController
- @file Defines the inline entity form controller for Nodes.
Code
public function entityForm($entity_form, &$form_state) {
$node = $entity_form['#entity'];
$type = node_type_get_type($node);
$extra_fields = field_info_extra_fields('node', $node->type, 'form');
// Do some prep work on the node, similarly to node_form().
if (!isset($node->title)) {
$node->title = NULL;
}
node_object_prepare($node);
$entity_form['title'] = array(
'#type' => 'textfield',
'#title' => check_plain($type->title_label),
'#required' => TRUE,
'#default_value' => $node->title,
'#maxlength' => 255,
// The label might be missing if the Title module has replaced it.
'#weight' => !empty($extra_fields['title']) ? $extra_fields['title']['weight'] : -5,
);
$entity_form['status'] = array(
'#type' => 'radios',
'#access' => user_access('administer nodes'),
'#title' => t('Status'),
'#default_value' => $node->status,
'#options' => array(
1 => t('Published'),
0 => t('Unpublished'),
),
'#required' => TRUE,
'#weight' => 99,
);
$langcode = entity_language('node', $node);
field_attach_form('node', $node, $entity_form, $form_state, $langcode);
return $entity_form;
}