Craft\NeoFieldType::getSettingsHtml PHP Method

getSettingsHtml() public method

Builds the HTML for the configurator.
public getSettingsHtml ( ) : string
return string
    public function getSettingsHtml()
    {
        // Disable creating Neo fields inside Matrix, SuperTable and potentially other field-grouping field types.
        if ($this->_getNamespaceDepth() > 2) {
            return '<span class="error">' . Craft::t("Unable to nest Neo fields.") . '</span>';
        }
        $settings = $this->getSettings();
        $jsBlockTypes = [];
        $jsGroups = [];
        foreach ($settings->getBlockTypes() as $blockType) {
            $fieldLayout = $blockType->getFieldLayout();
            $fieldLayoutTabs = $fieldLayout->getTabs();
            $jsFieldLayout = [];
            foreach ($fieldLayoutTabs as $tab) {
                $tabFields = $tab->getFields();
                $jsTabFields = [];
                foreach ($tabFields as $field) {
                    $jsTabFields[] = ['id' => $field->fieldId, 'required' => $field->required];
                }
                $jsFieldLayout[] = ['name' => $tab->name, 'fields' => $jsTabFields];
            }
            $jsBlockTypes[] = ['id' => $blockType->id, 'sortOrder' => $blockType->sortOrder, 'name' => $blockType->name, 'handle' => $blockType->handle, 'maxBlocks' => $blockType->maxBlocks, 'childBlocks' => $blockType->childBlocks, 'topLevel' => (bool) $blockType->topLevel, 'errors' => $blockType->getErrors(), 'fieldLayout' => $jsFieldLayout, 'fieldLayoutId' => $fieldLayout->id];
        }
        foreach ($settings->getGroups() as $group) {
            $jsGroups[] = ['id' => $group->id, 'sortOrder' => $group->sortOrder, 'name' => $group->name];
        }
        // Render the field layout designer HTML, but disregard any Javascript it outputs, as that'll be handled by Neo.
        craft()->templates->startJsBuffer();
        $fieldLayoutHtml = craft()->templates->render('_includes/fieldlayoutdesigner', ['fieldLayout' => false, 'instructions' => '']);
        craft()->templates->clearJsBuffer();
        $this->_includeResources('configurator', ['namespace' => craft()->templates->getNamespace(), 'blockTypes' => $jsBlockTypes, 'groups' => $jsGroups, 'fieldLayoutHtml' => $fieldLayoutHtml]);
        craft()->templates->includeTranslations("Block Types", "Block type", "Group", "Settings", "Field Layout", "Reorder", "Name", "What this block type will be called in the CP.", "Handle", "How you’ll refer to this block type in the templates.", "Max Blocks", "The maximum number of blocks of this type the field is allowed to have.", "All", "Child Blocks", "Which block types do you want to allow as children?", "Top Level", "Will this block type be allowed at the top level?", "Delete block type", "This can be left blank if you just want an unlabeled separator.", "Delete group");
        return craft()->templates->render('neo/_fieldtype/settings', ['settings' => $this->getSettings()]);
    }