public function onSaveFieldLayout(Event $e)
{
$fieldLayout = $e->params['layout'];
$postData = craft()->request->getPost('neo');
$blockType = craft()->neo->currentSavingBlockType;
if ($postData && $blockType) {
if (isset($postData['relabel'])) {
craft()->neo->requirePlugin('relabel');
$relabelPost = $postData['relabel'];
if ($relabelPost && array_key_exists($blockType->id, $relabelPost)) {
$relabelPost = $relabelPost[$blockType->id];
foreach ($relabelPost as $fieldId => $labelInfo) {
$labelModel = new RelabelModel();
$labelModel->fieldId = $fieldId;
$labelModel->fieldLayoutId = $fieldLayout->id;
if (array_key_exists('name', $labelInfo)) {
$labelModel->name = $labelInfo['name'];
}
if (array_key_exists('instructions', $labelInfo)) {
$labelModel->instructions = $labelInfo['instructions'];
}
$this->saveLabel($labelModel);
}
}
}
}
}