function makemeeting_edit_answer in Make Meeting Scheduler 7.2
Menu callback: edit an answer
Parameters
object $answer: The loaded answer
string $type: Ajax or nojs
Return value
array|void The entire form or just the row depending on ajax
1 string reference to 'makemeeting_edit_answer'
- makemeeting_menu in ./
makemeeting.module - Implements hook_menu().
File
- ./
makemeeting.pages.inc, line 44
Code
function makemeeting_edit_answer($answer, $type = 'ajax') {
$entities = entity_load($answer->entity_type, [
$answer->entity_id,
]);
if (empty($entities)) {
return drupal_not_found();
}
$entity = $entities[$answer->entity_id];
$field = $entity->{$answer->field_name}[$answer->language][$answer->delta];
$form = drupal_get_form('makemeeting_answers_form_' . $answer->entity_id, $field, (array) $answer, $answer);
if ($type == 'ajax') {
$form['#theme'] = 'makemeeting_answer_row';
// Replace 'ajax' word in form action
$form['#action'] = str_replace('/ajax/', '/nojs/', $form['#action']);
$colspan = 1 + count(element_children($form['answers']));
$output = '<tr class="editing"><td colspan="' . $colspan . '">' . drupal_render($form) . '</td></tr>';
$commands = [];
// See ajax_example_advanced.inc for more details on the available commands
// and how to use them.
$commands[] = ajax_command_replace('#answer-' . $answer->answer_id, $output);
$page = [
'#type' => 'ajax',
'#commands' => $commands,
];
return ajax_deliver($page);
}
return $form;
}