/** * @param ScaffoldFieldRendererConfig|DataRendererConfig $rendererConfig * @param ScaffoldFieldConfig|ItemDetailsFieldConfig $fieldConfig */ protected function configureDefaultRenderer(ScaffoldFieldRendererConfig $rendererConfig, ScaffoldFieldConfig $fieldConfig) { switch ($fieldConfig->getType()) { case $fieldConfig::TYPE_IMAGE: $rendererConfig->setView('cmf::details.image'); break; case $fieldConfig::TYPE_BOOL: $rendererConfig->setView('cmf::details.bool'); break; case $fieldConfig::TYPE_JSON_TREE: $rendererConfig->setView('cmf::details.json_tree'); break; default: $rendererConfig->setView('cmf::details.text'); } }
/** * @param CellRendererConfig|ScaffoldFieldRendererConfig $rendererConfig * @param DataGridFieldConfig|ScaffoldFieldConfig $fieldConfig */ protected function configureDefaultRenderer(ScaffoldFieldRendererConfig $rendererConfig, ScaffoldFieldConfig $fieldConfig) { switch ($fieldConfig->getType()) { case $fieldConfig::TYPE_IMAGE: $rendererConfig->setView('cmf::details/image'); break; } }
/** * @param InputRendererConfig|ScaffoldFieldRendererConfig $rendererConfig * @param FormFieldConfig|ScaffoldFieldConfig $fieldConfig * @throws \PeskyCMF\Scaffold\ScaffoldException * @throws \PeskyORM\Exception\DbColumnConfigException * @throws \PeskyCMF\Scaffold\ScaffoldFieldException */ protected function configureDefaultRenderer(ScaffoldFieldRendererConfig $rendererConfig, ScaffoldFieldConfig $fieldConfig) { switch ($fieldConfig->getType()) { case $fieldConfig::TYPE_BOOL: $rendererConfig->setView('cmf::input/trigger'); break; case $fieldConfig::TYPE_HIDDEN: $rendererConfig->setView('cmf::input/hidden'); break; case $fieldConfig::TYPE_TEXT: $rendererConfig->setView('cmf::input/textarea'); break; case $fieldConfig::TYPE_WYSIWYG: $rendererConfig->setView('cmf::input/wysiwyg'); break; case $fieldConfig::TYPE_SELECT: $rendererConfig->setView('cmf::input/select')->setOptions($fieldConfig->getOptions()); break; case $fieldConfig::TYPE_MULTISELECT: $rendererConfig->setView('cmf::input/multiselect')->setOptions($fieldConfig->getOptions()); if (!$fieldConfig->hasValueConverter() && in_array($fieldConfig->getTableColumnConfig()->getType(), [FormFieldConfig::TYPE_JSON, FormFieldConfig::TYPE_JSONB], true)) { $fieldConfig->setValueConverter(function ($value) { return $value; }); } break; case $fieldConfig::TYPE_TAGS: $rendererConfig->setView('cmf::input/tags'); $options = $fieldConfig->getOptions(); if (!empty($options)) { $rendererConfig->setOptions($options); } if (!$fieldConfig->hasValueConverter() && in_array($fieldConfig->getTableColumnConfig()->getType(), [FormFieldConfig::TYPE_JSON, FormFieldConfig::TYPE_JSONB], true)) { $fieldConfig->setValueConverter(function ($value) { return $value; }); } break; case $fieldConfig::TYPE_IMAGE: $rendererConfig->setView('cmf::input/image'); break; case $fieldConfig::TYPE_DATETIME: $rendererConfig->setView('cmf::input/datetime'); break; case $fieldConfig::TYPE_DATE: $rendererConfig->setView('cmf::input/date'); break; case $fieldConfig::TYPE_EMAIL: $rendererConfig->setView('cmf::input/text')->setAttributes(['type' => 'email']); break; case $fieldConfig::TYPE_PASSWORD: $rendererConfig->setView('cmf::input/password'); break; default: $rendererConfig->setView('cmf::input/text'); } if ($fieldConfig->isDbField()) { $this->configureRendererByColumnConfig($rendererConfig, $fieldConfig->getTableColumnConfig()); } if ($fieldConfig->hasDefaultRendererConfigurator()) { call_user_func($fieldConfig->getDefaultRendererConfigurator(), $rendererConfig, $fieldConfig); } }