I have some problems with typo 7.6.2
I would like to add my own content elements to the content-element wizard.
My own extension with templates, partials, TypoScript... worked and the element is visible in the content-element wizard.
Content-element Wizard
If I choose the new element and click the place to add the following screen is shown.
(ext_tables.php):
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
$_EXTKEY,
'Configuration/TypoScript',
'Template Extension'
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('
mod {
wizards.newContentElement.wizardItems.extra {
header = KCW Inhalte
elements {
mitglied {
icon = ../typo3/sysext/core/Resources/Public/Icons/T3Icons/content/content-header.svg
title = Mitglied
description = Ein Mitglied anlegen
tt_content_defValues {
CType = mitglied
}
}
}
show = *
}
}
');
"Configuration/TCA/Overrides/tt_content.php":
$TCA['mitglied'] = array(
'columns' => array(
'name' => array (
'exclude' => 1,
'label' => 'Vorname Name',
'config' => array (
'type' => 'input',
'size' => '20'
)
),
'spitzname' => array (
'exclude' => 1,
'label' => 'Spitzname',
'config' => array (
'type' => 'input',
'size' => '20'
)
),
'geburtstag' => array (
'exclude' => 1,
'label' => 'Geburtstag',
'config' => array (
'type' => 'input',
'size' => '10',
'eval' => 'date',
)
),
'posten' => array (
'exclude' => 1,
'label' => 'Posten',
'config' => array (
'type' => 'select',
'renderType' => 'selectSingle',
'items' => array (
array('Mitglied'),
array('Präsident'),
array('Kassenwart'),
array('Vergnügungsausschuss'),
),
'size' => 1,
'maxitems' => 1,
)
),
'foto' => array (
'exclude' => 1,
'label' => 'Foto',
'config' => array(
'type' => 'group',
'internal_type' => 'file',
'allowed' => 'jpg',
'max_size' => 1000,
'uploadfolder' => 'uploads/pics/',
'show_thumbs' => 1,
'size' => 3,
'minitems' => 1,
'maxitems' => 1,
'autoSizeMax' => 10,
)
),
),
'types' => array(
'0' => array('showitem' => 'name,spitzname,geburtstag,posten,foto')
)
);
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA']['tt_content'], $tcaTtContent);
I think the problem is located in these lines in ext_tables.php:
tt_content_defValues {
CType = mitglied
}
You have to allow the value mitglied as value of the field cType. The tt_content_devValues just sets the default values for the newly created content element.
TCEFORM.tt_content.cType.addItems.mitglied = Field title
https://docs.typo3.org/typo3cms/TSconfigReference/PageTsconfig/TCEform/Index.html#pagetceformconfobj
Related
Hi guys I am struggling with TYPO3 and I would like to do a search filter on my select.
I have this TCA for my select. I added there also this 'enableMultiSelectFilterTextfield' => true, but nothing changes. Is there a way how to achieve this?
$fields = array(
'my_plugin' => array(
'label' => 'my Fields',
'exclude' => 1,
'config' => array(
'type' => 'select',
'enableMultiSelectFilterTextfield' => true,
'maxitems' => 99999,
'itemsProcFunc' => 'tx_get_list->getList',
'items' => array(
),
),
)
);
At my standard content elements text & media the fullscreen mode for RTE (htmlarea, Rich-Text-Editor) is working fine.
But - I've wrote an extension (via extension builder) and if I try to use the RTE in fullscreen, I've got the following error:
Module wizard_rich_text_editor is not configured
Here's my TCA, where's my error? The 'TYPO3-RTE' is working fine, so there must be an error in my following code. What do you think?
'description' => array(
'exclude' => 1,
'label' => 'LLL:EXT:xyz/Resources/Private/Language/locallang_db.xlf:tx_xyz_domain_model_product.description',
'config' => array(
'type' => 'text',
'cols' => 40,
'rows' => 15,
'eval' => 'trim',
'wizards' => array(
'RTE' => array(
'icon' => 'wizard_rte2.gif',
'notNewRecords'=> 1,
'RTEonly' => 1,
'module' => array(
'name' => 'wizard_rich_text_editor',
'urlParameters' => array(
'mode' => 'wizard',
'act' => 'wizard_rte.php'
)
),
'title' => 'LLL:EXT:cms/locallang_ttc.xlf:bodytext.W.RTE',
'type' => 'script'
)
)
),
),
Does anyone know the problem? Thanks for your help.
Regards,
Stefan
A working example for TYPO3 7.x and 8 is
'bodytext' => [
'exclude' => 0,
'l10n_mode' => 'noCopy',
'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:bodytext_formlabel',
'config' => [
'type' => 'text',
'cols' => 30,
'rows' => 5,
'softref' => 'rtehtmlarea_images,typolink_tag,images,email[subst],url',
'wizards' => [
'_PADDING' => 2,
'RTE' => [
'notNewRecords' => 1,
'RTEonly' => 1,
'type' => 'script',
'title' => 'Full screen Rich Text Editing',
'icon' => 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_rte.gif',
'module' => [
'name' => 'wizard_rte',
],
],
],
]
],
The name should be wizard_rte.
I can't figure out from official docs how to build a single checkbox element from the standard helpers. I already have the relevant boolean entity in database and I can build radios or selects as well for it, and they work.
But what I'd really like is to have a single checkbox to use as a boolean flag.
Anyone knows how?
Ok, the answer is to just use the 'switch' type: that will build a 'slider' switch on backoffice page. For future reference, I'm gonna report 3 different ways to accomplish the same task: radio, select and switch.
They have all been tested on AdminAddressesController and are bound to a custom DB boolean field called 'expo'.
//SELECT
$s_options = array(
array( 'expo' => 1, 'name' => 'Yes' ),
array( 'expo' => 0, 'name' => 'No' )
);
$temp_fields[] = array(
'type' => 'select',
'label' => $this->l('Is Expo'),
'name' => 'expo',
'required' => false,
'options' => array(
'query' => $s_options,
'id' => 'expo',
'name' => 'name'
)
);
//RADIO
$s_options = array(
array( 'id' => 'expo_on', 'value' => 1, 'label' => $this->l('Yes')),
array( 'id' => 'expo_off', 'value' => 0, 'label' => $this->l('No')),
);
$temp_fields[] = array(
'type' => 'radio',
'label' => $this->l('Is Expo'),
'name' => 'expo',
'required' => false,
'class' => 't',
'is_bool' => true,
'values' => $s_options
);
//SWITCH
$s_options = array(
array( 'id' => 'expo_on', 'value' => 1, 'label' => $this->l('Yes')),
array( 'id' => 'expo_off', 'value' => 0, 'label' => $this->l('No')),
);
$temp_fields[] = array(
'type' => 'switch',
'label' => $this->l('Is Expo'),
'name' => 'expo',
'required' => false,
'is_bool' => true,
'values' => $s_options
);
I have made in backend a TCA form, what will change depending of the value in select field "type":
This select field contains basically the options:
rte text
url
picture
I can make the system working so, that when "rte text" is chosen, it shows specified fields for "rte text", when url is chosen it shows specified fields for "url" etc..
In my case the content is always saved in database in field "content" and the selected type is saved in field "type".
My problem is that I have not found a way to change the "content" form field / configuration, depending on the selected type.
For example when I choose "rte text" it should use for the content field this kind of configuration (rich text editor):
'content' => array (
'exclude' => 0,
'label' => 'Content',
'config' => array (
'type' => 'text',
'cols' => '30',
'rows' => '5',
'wizards' => array(
'_PADDING' => 2,
'RTE' => array(
'notNewRecords' => 1,
'RTEonly' => 1,
'type' => 'script',
'title' => 'Full screen Rich Text Editing|Formatteret redigering i hele vinduet',
'icon' => 'wizard_rte2.gif',
'script' => 'wizard_rte.php',
),
),
)
),
and when I choose "picture" it should use for the content field this kind of configuration (file uploader):
'content' => array (
'exclude' => 0,
'label' => 'Content',
'config' => array (
'type' => 'group',
'internal_type' => 'file',
'allowed' => '',
'disallowed' => 'php,php3',
'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
'uploadfolder' => 'uploads/tx_uploadshere',
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
)
),
Is there a way to change that configuration depending of the value in the selectbox. I have tried to put two contents in an array but haven't got it working on that way.
Unfortunately you cannot change the properties of a single field via type.
You can however influence what's being displayed. So you can configure two independent fields and switch the display:
ext_tables.php:
$TCA['tx_yourextension_yourtable'] = array(
'ctrl' => array(
//...
'type'=>'type',
//...
),
);
TCA.php:
$TCA['tx_yourextension_yourtable'] = array(
'ctrl' => $TCA['tx_yourextension_yourtable']['ctrl'],
'types' => array(
0 => array('showitem' => 'content_rte'),
1 => array('showitem' => 'content_image'),
),
'columns' => array(
'content_rte' => array(
'exclude' => 0,
'label' => 'Content',
'config' => array(
'type' => 'text',
'cols' => '30',
'rows' => '5',
'wizards' => array(
'_PADDING' => 2,
'RTE' => array(
'notNewRecords' => 1,
'RTEonly' => 1,
'type' => 'script',
'title' => 'Full screen Rich Text Editing|Formatteret redigering i hele vinduet',
'icon' => 'wizard_rte2.gif',
'script' => 'wizard_rte.php',
),
),
)
),
'content_upload' => array(
'exclude' => 0,
'label' => 'Content',
'config' => array(
'type' => 'group',
'internal_type' => 'file',
'allowed' => '',
'disallowed' => 'php,php3',
'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
'uploadfolder' => 'uploads/tx_uploadshere',
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
)
),
),
// ...
);
(Note: I've removed system fields like hidden, sys_language_uid etc. for simplicity's sake)
i have this form:
$this->addElement (
'multiCheckbox', 'servers2',
array (
'checkedValue' => '0',
'multiOptions' => array(
'11.com' => '.com',
'12.com' => '12.com',
'16.com' => '16.com',
'3.com' => '17.com'
)
));
the problem is that the checkedValue doesn't work for this setup, it does for a simple checkbox. I've also tried 'checkedValues' => array('1','0'), singular or plural,
but no end in sight.
any ideas?
THanks
To mark certain checkboxes as checked, try this:
$multiCheckElement->setValue(array('11.com', '3.com'));
// or
$this->addElement (
'multiCheckbox', 'servers2',
array (
'value' => array('11.com', '3.com'), // select these 2 values
'multiOptions' => array(
'11.com' => '.com',
'12.com' => '12.com',
'16.com' => '16.com',
'3.com' => '17.com'
)
)
);
See also Zend_Form_Element_MultiCheckbox
ZF2 will require you to use value_options;
$form->add(
array(
'name' => 'servers2',
'type' => \Zend\Form\Element\MultiCheckbox::class,
'attributes' => array(
'id' => 'servers2',
'class' => 'form-control',
),
'options' => array(
'label' => 'Servers 2',
'column-size' => 'sm-10',
'label_attributes' => array('class' => 'col-sm-2'),
'twb-layout' => 'horizontal',
'value_options' => array(
'11.com' => '.com',
'12.com' => '12.com',
'16.com' => '16.com',
'3.com' => '17.com'
)
),
)
);
To specify the checked options, as seen at
use the 'selected' => true attribute:
$options = array(
array(
'value' => '0',
'label' => 'Apple',
'selected' => false,
'disabled' => false,
'attributes' => array(
'id' => 'apple_option',
'data-fruit' => 'apple',
),
'label_attributes' => array(
'id' => 'apple_label',
),
),
array(
'value' => '1',
'label' => 'Orange',
'selected' => true,
),
array(
'value' => '2',
'label' => 'Lemon',
),
);