protected function create($data)
{
$display = $this->getDisplay();
$createForm = $display->createForm();
$createForm->addAttribute('autocomplete', 'off');
$this->runTransformations($data);
$errors = $createForm->validate($data);
if ($errors) {
$data = array('error' => 1, 'errors' => $errors);
} else {
$newData = $createForm->filterValues($data);
$callables = $this->subgridConfig->beforeCreate();
if ($callables) {
if (is_array($callables) && !is_callable($callables)) {
foreach ($callables as $callable) {
call_user_func($callable, $newData);
}
} else {
call_user_func($callables, $newData);
}
}
$actions = $this->getActions();
$recordId = $actions->create($newData);
$callables = $this->subgridConfig->afterCreate();
if ($callables) {
if (is_array($callables) && !is_callable($callables)) {
foreach ($callables as $callable) {
call_user_func($callable, $recordId, $newData);
}
} else {
call_user_func($callables, $recordId, $newData);
}
}
$display = $this->getDisplay();
$html = $display->fullHtml();
$commands[] = Commands::setHtml($html);
$data = array('error' => 0, 'commands' => $commands);
}
return $data;
}