$GLOBALS['TCA']['tt_content']['types'][$myCType]['columnsOverrides']['imagecols']['config']['items'] not overriding default list - typo3

$GLOBALS['TCA']['tt_content']['types'][$myCType]['columnsOverrides']['imagecols']['config']['items'] = [[2,2],[3,3]];
But above not working it just replace fist two items with my list but other items are still visible how can i override items array for my custom ctype?

It seems, \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule(), which is used to handle the columnsOverrides, does allow unsetting a key (or array), but not replacing a substructure.
Maybe it's possible to find a combination of unsetting and afterwards merging with new values.

In this case you can use TCEFORM to solve your task.
TCEFORM.tt_content.imagecols.types.myCType.keepItems = 2,3

Related

How to replace the user/contact form in Sulu?

I want to know how to change/replace the user/contact form in Sulu i.e. https://sulu.rocks/admin/#/contacts/1/details.
I want to remove the fields for Addresses, Bank accounts, etc.
I tried to copy the vendor/sulu/sulu/src/Sulu/Bundle/ContactBundle/Resources/config/forms/account_details.xml into config/forms and removed the unnecessary fields. But that not working.
I can't find something to this in the documentation or it's hidden :D
If you add a form with the exact same key as the form you want to override, the contents of both forms are merged. In your case, the key would be contact_details. Now you can add completely new properties to the form or override existing ones by just creating a property with the same name. If you want to hide a property, you have to override it and set visibleCondition="false".
You can also have a look at this example pull request.

How to remove a field from `showitems` in TCA?

TYPO3 has the function TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes() to add or replace one or more fields to the BE form of a record.
How can we remove fields?
(replacing by '' does not work)
Explanation:
Its about hiding some fields in tt_content for some CTypes only.
In the past we did it by overwriting the complete value. But with the upgrade from 6.2LTS to 8LTS we run into problems as the default labels have changed (pathes to the language files) and so some labels become lost in the BE, which was noticed very late.
Now I want a clean way to remove single fields so that the definition of the remaining fields stays clean with the default values from core (or other extensions).
Other extensiosn which add their own fields also are a problem if the value is set with a static string: these fields are also removed.
Since there is indeed no way to insert an empty string, you could create an empty palette instead. This way you will still get a non empty string to insert, but it will not create any output in the form.
addToAllTCAtypes('table', '--palette--;;empty', '', 'replace:fieldname')
And you should make a feature request, to make at least the replacement with an empty string possible in upcoming versions of TYPO3.
Do it in the code like this:
foreach ($GLOBALS['TCA']['yourtablenamehere']['types'] as &$definition) {
$definition['showitems'] = '';
}
if you only need to reset a specific type ('0', for example):
$GLOBALS['TCA']['yourtablenamehere']['types']['0']['showitems'] = '';
If you want to override types completely instead of clearing them (clearing only does not much sense anyway):
$GLOBALS['TCA']['yourtablenamehere']['types']['0']['showitems'] = 'title, bodytext';

Best way to remove an element in an XML using anti-xml

What would be the best and/or simplest way to remove an element from a XML document using anti-xml?
Here is one way:
(xml \ "nodeToRemove").filter { _.name != "nodeToRemove"}.unselect.head
Any others?
Not sure whether this is better or not, but you could use the drop method, like so:
(xml \\ 'nodeToRemove drop 1).unselect.head
which assumes a single occurrence of nodeToRemove; you can drop all items in the resulting Zipper if there is more than one occurrence.
Also, as the drop complements, the take and slice methods remove anything that's not included in their ranges.

Extjs 4 :Disable all the input elemets in an Extjs form at once

I have created a extjs form which is divided into 2 parts using column layout and have almost 10-15 input elements in it. How can i disable all these input elements at a time depending on a condition. Currently i have created a function which fetchs all the components in a form and using ext.each loop through each element to disable them
Here is the function that i use
function prepare_form_view(form){
var f=Ext.getCmp(form);
var els=f.query('component');
Ext.each(els,function(o){
var xtype=o.getXType();
if(xtype=='textfield'||xtype=='combobox'||xtype=='datefield'||xtype=='textareafield'||xtype=='button'){
o.disabledCls='myDisabledClass';
o.disable();
}
});
}
Is there any alternative way so that I can disable all elements without looping through each and every elements. I want to use this function with other forms too. I looking for something like 'setFieldDefult' function.
If you are using FormPanel in ExtJs 4.x this is what you are looking for -
yourFormPanel.getForm().applyToFields({disabled:true});
The getForm() method returns the Ext.form.Basic object, with this class, you also could access to all the fields on this form with getFields(), then you could iterator all the fields to do anything.
Hope this helps and good luck:-)
What about panel's disable/enable method? This seems much easier.
panel.disable();
panel.enable();
Here is a suggestion.. Since, you say your form is divided into two parts why don't you put them in a FieldSet ? You can disable the fieldset as a whole with one method ie, setDisabled.
This will avoid the looping of components and disabling / enabling them one after the another.
You could use the cascade function of the form panel which is the ExtJs way to to do it but if you check the source code of the cascade function you will see that it uses a for loop also. The only benifit of using the cascade function is that it will work also for forms with nested panels. I think that your implementation will not work properly a case like that.

symfony form - delete embedded form object

I have a two Symfony forms:
ShoppingListForm
ShoppingListItemForm
I'm embedding the ShoppingListItemForm inside the ShoppingListForm many times. i.e. A shopping list contains many items.
So the ShoppingListItemForm consists of two widgets:
item_id (checkbox)
shopping_list_id (hidden - foreign key)
What I would like to do is delete the corresponding ShoppingListItem object if the object exists and the checkbox is left unchecked.
I'm not sure how this delete would occur? Would I use a post validator to see which fields have/haven't been checked? I'm a bit lost on this one.
I'd do this by over-riding the ShoppingListForm's updateObject method and putting your custom delete() etc calls in there (be sure to call parent::updateObject() within it).
Depending how you implement it, you may also need to remove the embedded forms and their values to ensure saving still works correctly for the remaining objects. Try without, but if you do, you need to clear the following:
unset($taintedValues['ShoppingListItem'][$key]);
unset($this->embeddedForms['ShoppingListItem'][$key]);
unset($this->validatorSchema['ShoppingListItem'][$key]);
unset($taintedFiles['ShoppingListItem'][$key]);
If you want to see a custom updateObject method to get an idea how to interact with values etc:
http://www.symfony-project.org/forms/1_2/en/11-Doctrine-Integration#chapter_11_sub_customizing_the_updateobject_method
personnally, I would loop through the existing list items to see whether the corresponding checkboxes are checked in the action, and call the delete() method on the items for which it is not the case. I don't think it is the purpose of a post validator, I would do this directly in the action.