Applying decorator to specific type e.g. text or select - zend-framework

I'm know how to add custom decorators and use view helpers to set decorators for named elements.
Is their a method or an attribute that would allow me to set a default decorator for all textareas or for all text inputs or all selects?
Thank you

yes you can override default zend decorator for your html object like textarea or text box
here is good example to create our own decomrator Link

Related

Wrap H1-H6 Tags with Typo3 ParseFunc depending on the class set in RTE

I want to add inline-svgs to my h1 to h6 Tags depending on the class set in the RTE.
Example:
RTE:
<h1 class="icon--clock">Header</h1>
Output:
<h1 class="icon--clock"><svg>...</svg>Header</h1>
I've done something similar with links before, using the parseFunc Config. A method like this: https://wiki.typo3.org/External_links
Is there any way to access and split the tag and class like the link parameters through TypoScript?
I also tried using a userFunc
lib.parseFunc.userFunc = ...\MyClass->MyUserFunc
but in Params I only get the tag content, not the tag or the classes that have been set themselves.
I'm using Typo8 with the ckeditor, but I don't think that makes a difference.
Can I even do this?
How do I do this?
I know that I can alternatively add different header layouts and use the tt_content header field, because it's easier to manipulate the template there. But I'd love to know if there is a way to this in the RTE.
I think you could do it in typoscript, but that would be very complicated as you need to analyze the attributes of the Hn-tags.
A simpler method which came to mind would be: use CSS and ::before. So you can use a selector to the class to insert the matching SVG.
This also can be done with javascript but as CSS can do it it would be more efficient to use CSS.

how to disable fields in tca only for certain ctypes

I want to disable certain fields in the backend, e.g. many fields of gridelements and other content elements. I know about the possibilities of TCEFORM but it allowes only to disable a field in all cTypes. I need a way to disable certain field only for certain cTypes.
Is there a way to achieve this?
Thanks
You have full control over which field are shown, if you adapt TCA for tt_content. You can override TCA with your customer extensions (sitepackage).
The following file contains fields, which are shown for CType header (TYPO3 CMS 7.6)
EXT:sitepackage/Configuration/TCA/Overrides/tt_content.php
<?php
defined('TYPO3_MODE') or die();
call_user_func(function () {
$GLOBALS['TCA']['tt_content']['types']['header']['showitem'] = '--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.headers;headers,rowDescription,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.frames;frames,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.visibility;visibility,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.access;access,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.extended,--div--;LLL:EXT:lang/locallang_tca.xlf:sys_category.tabs.category,categories';
});
Remove or add any fields after your needs and do so for any CType you wish to change.
See also https://docs.typo3.org/typo3cms/TCAReference/7.6/Reference/Types/Index.html
Meanwhile (since 9 LTS) it is possible via TsConfig:
TCEFORM.tt_content.subheader.types.text.disabled = 1
… disables the subheader field for all text content elements.
You can even disable a field for all cTypes and define an exception:
TCEFORM.tt_content.subheader{
disabled = 1
types.text.disabled = 0
}
As long as you don't need additional conditions like i.e. a certain user or group or a particular branch of the page tree to disable these fields, you should not go for PageTSconfig and TCEFORM but pure TCA types instead.
Just create a site package extension, which would be recommended anyway, and make sure to provide the desired setup for the tt_content table within Configuration/TCA/Overrides/tt_content.php so it will be applied automatically.
You can find some slides about the "Anatomy of Sitepackages" here: https://de.slideshare.net/benjaminkott/typo3-the-anatomy-of-sitepackages
Additional information about the TCA types can be found here:
https://docs.typo3.org/typo3cms/TCAReference/Types/Index.html
As Gridelements just provides mandatory fields for layout, children, container and column, you should not disable these fields though, since it might break the functionality.

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.

Declarative Initialization list width kendo autocomplete

Is there any way to decoratively define the List width in the HTML.
I know I can do it
var autoComplete = $("#autoComplete").data("kendoAutoComplete");
// set width of the drop-down list
autoComplete.list.width(400);
but I want to do it in HTML only.
I have already tried:
data-list-width="400"
When you create an autocomplete in Kendo UI, it creates a second HTML element (a wrapper) for the drop down options. This element is given as id the id of the original one plus -list.
You can define a CSS style for this newly created wrapper as:
#autocomplete-list {
width: 300px !important;
}
You need to use !important otherwise the value calculated by Kendo UI has prevalence over yours.
Example in this JS Fiddle: http://jsfiddle.net/OnaBai/n55w8/
I got the answer from telerik today:
Currently, the width of the popup element can be set only programatically.
Salam!
The .width(400) is not a configuration setting, it is jQuery width method, so you can't set width for your autocomplete decoratively.
If you use MVVM framework in your project, maybe Custom binding help you to add a custom binding like <input id="autoComplete" data-bind="listwidth: 400" /> for your autocomplete.
See this demo if you want to use custom binding.

Zend framework decorators question

I need to add some random html content with text before and after my input field.
I know I can use description decorator and set escape option to false - this way I can simply inject arbitrary html chunk as a decorator.
But this only accounts for 1 html chunk - I need a second one after input field. If I simply output description decorator again after input field - that will output the same description chucnk.
1) Is there a way to use description decorator multiple times with different content?
2) In label decorator - is there a way to use span tag instead of label tag?
3) Can I inject random html into HtmlTag decorator?
thanks!
update:
i solved my problem by creating simple custom decorator that allows me inject random html anywhere. Still -if someone knows quick and easy answers - plz post.
You could check out the AnyMarkup decorator:
http://www.zfsnippets.com/snippets/view/id/62/anymarkup-decorator