TYPO3: Set type specific default values in TCA - typo3

In my environment it is possible to set the default value for all content elements using
$GLOBALS['TCA']['tt_content']['columns']['rowDescription']['config']['default'] = 'Default Value';
But overriding for one specific content element is not possible:
$GLOBALS['TCA']['tt_content']['types']['new_ce']['columnsOverrides']['rowDescription']['config']['default'] = 'New Description';
All other configurations can be changed (like the label):
$GLOBALS['TCA']['tt_content']['types']['new_ce']['columnsOverrides']['rowDescription']['label']= 'This is the new label';
How can I modify the default value for new_ce?

Afaik not possible currently.
Technical reason in formEngine is that the TCA value defaults are applied before the 'type' is calculated since the default values influence type determination. Thus, they can't be swapped.
Also, this is not possible via page TSconfig since TCAdefaults also handles no type specific settings.

Related

Vue Element UI - Default el-input-number to empty field instead of a number

Creating a form with no values and would like the input field to default to empty for two reasons:
Want users to be able to see the placeholder text.
Having a default number means the users can ignore the field by default. (I know I can validate the field, but that is just a bad user experience.)
The problem:
el-input-number fields default to a number (0 or whatever the :min value is set to).
This covers up the placeholder text.
The users can click save with the default number still in place. (I will validate, but don't want users to have to submit a bad value to know what to do.)
Does anyone know how to make the input field have the default value be just empty?
just give it a default value of undefined
https://codepen.io/rugia/pen/bGEoWaB?editors=1010

TCA configuration: Value of field should be copied to translated record

I am adding a field to the pages table (is a relation to a file) and would like the value of the field in the pages record to be copied to the translated record by default.
Currently, the copied field is empty (default value), which is probably a good idea in most cases.
I am thinking of something that behaves like l10n_mode = prefixLangTitle without the prefix.
Depending on the TYPO3 version this should be possible with one of the following behaviours for the inline field:
https://docs.typo3.org/typo3cms/TCAReference/7.6/Reference/Columns/Inline/Index.html#behaviour
https://docs.typo3.org/typo3cms/TCAReference/8.7/ColumnsConfig/Type/Inline.html#localizechildrenatparentlocalization
https://docs.typo3.org/typo3cms/TCAReference/latest/ColumnsConfig/Type/Inline.html#allowlanguagesynchronization
Sine the localizeChildrenWithParentLocalization feature is broken with pages and pages_language_overlay though, I guess the only working versions would be CMS 8 or 9 with properly configured language synchronization.
https://forge.typo3.org/issues/78743
Use
['behaviour']['allowLanguageSynchronization'] => true
if the translated record will use the value from the default field by
default (will effectively be copied), but it should be possible to change
this later.
See pages.author as example.
When "Custom value" is selected, the value can be overridden.
Alternativively, use
l10n_mode = exclude
if the field should always have the value of the default language and you
should not be able to change it in the translated record.

Content element hidden in default language should be visible in translation

Small problem with translated content in TYPO3 8.7.13:
Translation in connected mode. In default language there is one element hidden which should be visible in translation. In the backend it looks like it would be visible but in the frontend the element is missing. (The other way round there is no problem: when the element in default language is visible i can always hide it in the translation.)
My language configuration:
[sys_language_mode] = content_fallback
[sys_language_overlay] = hideNonTranslated
Translation in connected mode (we use L10N-Manager)
Is there a possiblity to make the translated element visible in the foreign language even when the element in the default language is hidden?
Thanks!
I'm not sure if my informations are up to date, but when I had similar case in older TYPO3 versions there were no way to achieve that. The workaround which I've used was to change type type (CType) of content element to "Empty", which was custom content element prepared especially for such cases. It is possible also to change the type to "Plain HTML" and just leave the bodytext empty.

Web2py: how to set contents of a textarea after it is defined

I'm using web2py to create an SQLFORM which updates some (currently empty) text fields:
form = SQLFORM(db.table, db.table(1), fields = ['blank_name'])
Which creates a textarea tag with name='blank_name'. I then want to set the default text for this text area to some variable. So I've tried
form.element(_name='blank_name').update(_value='My default value')
but this just sets the 'value' attribute of the textarea to 'My default value'. How can I set the contents of the previously blank textarea to a value?
The simplest approach is simple to set the field default (before creating the form):
db.table.blank_name.default = 'My default value'
Regarding the original approach, the web2py HTML helpers act like lists with regard to their components (i.e., contents), so you could use the .append or .insert methods to update the contents.

Zend form change elements required options to false at runtime

I have a form and having two file upload elements. it is like
$data_file_one = $this->createElement('file','data_file_one');
$data_file_one->setRequired(true)
->addValidator('Extension', false, 'csv')
->setDestination($filepath);
Both are set to required true. I use the same form for new post and edit posts. When it is used for editing the file upload should not be mandatory and must be set to required false. So, I need to change
setRequired(true) to setRequired(false)
How can I do when edit action is called to load form and change this element option?
Thanks in advance.
Zend_Forms have a method called getElement that allow you to retrieve an element from a form by its name. This gives you the ability to modify an element's default value before rendering it to the user.
For example, to change a field from being required to being optional, you can do the following:
$form->getElement('data_file_one')->setRequired(false);