function ajax_form_entity_entity_edit_callback in Ajax form entity 7
Same name and namespace in other branches
- 7.x ajax_form_entity.callback.inc \ajax_form_entity_entity_edit_callback()
Ajax callback for edition (ajax edit link).
1 string reference to 'ajax_form_entity_entity_edit_callback'
- ajax_form_entity_menu in ./
ajax_form_entity.module - Implements hook_menu().
File
- ./
ajax_form_entity.callback.inc, line 6
Code
function ajax_form_entity_entity_edit_callback($type = 'ajax') {
// TODO : use hook_menu page argument.
$entity_type = arg(3);
$entity_id = arg(4);
$special_id = arg(5);
// Load entity.
$ids[] = $entity_id;
$entity = entity_load($entity_type, $ids);
// TODO : desactivated js compatibility.
if (entity_access('update', $entity_type, $entity[$entity_id])) {
if ($type == 'ajax') {
$form_state['build_info']['args'][] = $entity;
$form['#prefix'] = '<div id="form-closing-wrapper-' . $special_id . '">';
$form['#suffix'] = '</div>';
$form = _ajax_form_entity_build_entity_forms($entity_type, array(), array(), $entity);
$form['#prefix'] .= l(t('Close'), 'ajax-form-entity-cancel/nojs/' . $special_id, array(
'attributes' => array(
'class' => array(
'use-ajax button-cancel',
),
),
));
$render_form = drupal_render($form);
$commands = array();
$commands[] = ajax_command_css('#ajax-entity-form-' . $special_id, array(
'display' => 'none',
));
$commands[] = ajax_command_append('#ajax-entity-form-wrapper-' . $special_id, $render_form);
$page = array(
'#type' => 'ajax',
'#commands' => $commands,
);
ajax_deliver($page);
}
else {
// TODO : no javascript.
}
}
}