Silverstripe 3 - add css class to CMS form field - silverstripe

How can I go about add a css class to the CheckboxSetField below - I've tried the setAttribute method but it has no effect (using SS 3.0):
$checkboxFieldSet = new CheckboxSetField('CampusPage', 'Campuses (select multiple)*', $campusArea->map());

$checkboxFieldSet->addExtraClass("my-class");
API Docs: http://api.silverstripe.org/3.1/class-FormField.html#_addExtraClass

Related

override "src" controller back office in prestashop

Firstly, I tried all the questions & answers related to this topic. Additionally and I tried related questions and try to solve it but no success. So please read my question thoroughly.
i refer below Link this topic but not getting solution
override-core-files-using-module-prestashop
override-controller-in-prestashop-1-6
prestashop-translating-overrided-controller
prestashop-1-6-controller-override
i want to this override prestashopbundle controller using my custom module.
my Custom module structure
- mymodule
- controllers
- admin
- prestashop
- override
- views
i want to this controller override
prestashop/src/prestashopbundle/controller/Admin/sell/Customer/CustomerController.php
mymodule path
module/mymodule/
Thanks
After Long Time research in Prestashop after then i got best Solution
Prestashop(1.7.*) say :
As Controllers are not available for override and can be regarded as
internal classes, we don’t consider moving a Controller in another
namespace as a backward-compatibility break.
Controller and Routing
After i created a custom Hook register my custom Module. inside custom hook implement functionality and DONE it :)
public function hookActionViewCustomers($params)
{
$creddit = Configuration::get('Credit_Checkbox_1');
$customerid =$params['request']->attributes->get('customerId');
$Status_HTMl =$this->Get_Status_HTML($customerid);
if(!$creddit)
{
// Checkbox Checked
$ButtonDisable =" <button type=\"submit\" disabled='disabled' title='Not Allow'> Check Status </button>";
}
else{
// Checkbox unChecked
$ButtonDisable =" <button type=\"submit\" title='Click Get Status'> Check Status </button>";
}
return $Status_HTMl.$ButtonDisable;
}

setting rowsPerPageOptions in alfresco share document library pagination section

I need to enable rowsPerPageOptions in documentLibrary paginator section.I found that paginator is configured in _setupHistoryManagers function in OOTB documentlist.js. so I have created documentlist-custom.js and overwrite entire function[_setupHistoryManagers] that exists in OOB documentlist.js and put it in my custom js file.it working fine.
But I want to know Is it the right way or Is there any way setting the adding this rowsPerPageOptions option in this.widgets.paginator function instead of copying whole _setupHistoryManagers function in custom js file?
using 4.2.2 version.
_setupHistoryManagers
{
// YUI Paginator definition
this.widgets.paginator = new YAHOO.widget.Paginator(
{
containers: [this.id + "-paginator", this.id + "-paginatorBottom"],
rowsPerPage: this.options.pageSize,
initialPage: this.currentPage,
rowsPerPageOptions: [25,50,75,100,500],
template: this.msg("pagination.template"),
pageReportTemplate: this.msg("pagination.template.page-report"),
previousPageLinkLabel: this.msg("pagination.previousPageLinkLabel"),
nextPageLinkLabel: this.msg("pagination.nextPageLinkLabel")
});
}

z3c.form and Plone - add custom css file to a form without using a custom template

In a project I'm working on we've defined a simple z3c.form, it looks like this.
class IImportCandidateForm(Interface):
csv_file = NamedFile(title=_(u'CSV file'))
class ImportForm(form.Form):
fields = field.Fields(IImportForm)
ignoreContext = True
def updateWidget(self):
super(ImportForm, self).updateWidget()
... snip ...
#button.buttonAndHandler(u'Import')
def handleImport(self, action):
data, errors = self.extractData()
if errors:
self.status = self.formErrorMessage
return
file = data["csv_file"].data
Is there a way to associate a custom css file with this form without first wrapping it in a custom page template with the form?
No, there isn't. Unless you use a form wrapper, the form's template renders only the form and not the entire page.
In you are using this form in a custom view, you have a class style added to the body class (something like template-yourviewname). So you can add you CSS rules to a main CSS resource, loaded in every page, but prefix every rule with .template-yourviewname.

Allow custom HTML attributes in TinyMCE in EPiServer

EPiServer only:
Our clients are trying to add custom attributes to a div-tag in the TinyMCE editor - they switch to HTML mode, makes the changes and save the page. Then the attributes are removed. Washing HTML like this is standard behaviour of TinyMCE, and it is possible to configure it to allow custom tag attributes.
My question is how do I configure TinyMCE in EPiServer to allow custom HTML attributes? I don't see where I would be able to hook into the inititialization of TinyMCE. And adding div to the list of "safe" tags in episerver.config doesn't see to work either (see uiSafeHtmlTags).
Example:
<div class="fb-like" data-href="http://oursite" data-send="false"></div>
Becomes just
<div class="fb-like"></div>
From the TinyMCE documentation, on how to add custom attributes to tags: http://www.tinymce.com/wiki.php/Configuration:extended_valid_elements
I have this class
using EPiServer.Editor.TinyMCE;
namespace SomeNamespace
{
[TinyMCEPluginNonVisual(
AlwaysEnabled = true,
EditorInitConfigurationOptions = "{ extended_valid_elements: 'iframe[src|frameborder=0|alt|title|width|height|align|name]' }")]
public class ExtendedValidElements { }
}
and this in episerver.config:
<episerver>
....
<tinyMCE mergedConfigurationProperties="valid_elements, extended_valid_elements, invalid_elements, valid_child_elements" />
</episerver>
in a recent project. It should work the same if you change the iframe part to div[data-href|data-send].
You have 2 options:
First
[TinyMCEPluginNonVisual(EditorInitConfigurationOptions = "{ extended_valid_elements: 'div[title|data-test]' }")]
will allow title and data-test in div tag.
div[*] will allow all attribute in div tag.
Second
make your TinyMCE plugin inherits from IDynamicConfigurationOptions
implement function like this:
public IDictionary<string, object> GetConfigurationOptions(){
var customSettings = new Dictionary<string, object>();
customSettings.Add("extended_valid_elements", "div[*]");
return customSettings;
}
No need to configure anything in .config file (with EPiServer's default value, they are all fine).
Here are some helpful links to this question
http://www.kloojed.com/2010/05/customize-the-tiny-mce-editor-options-in-episerver-cms-6
http://krompaco.nu/2010/05/alter-default-initoptions-for-tinymce-in-episerver-6/
http://world.episerver.com/Modules/Forum/Pages/thread.aspx?id=45795
The following worked for me:
[TinyMCEPluginNonVisual(AlwaysEnabled = true, EditorInitConfigurationOptions = "{ extended_valid_elements: 'div[*]' }", PlugInName = "ExtendedValidElements", ServerSideOnly = true)]
public class TinyMceExtendedValidElements
{
}
No changes in config.

CKEditor.net table class

In a asp.net C# webapp I'm using the CKEditor 3.6.2 and I'm facing the following problem:
In my stylesheet I have a CSS class to use in tables and I'm trying to bring this class already filled in the "Table properties", "Advanced" tab and the "Stylesheet Classes" field.
I want to bring this field filled with the string "blue_table", which is the name of my CSS class. I'm working with the source of the "table" plugin. I have figured out how to change the value of fields like width and height, but the one I want is the "Stylesheet Classes" field.
Do any of you know to to set a default value for this field?
You don't have to edit the ckeditor.js file to customise the editor. You can add the following either to config.js and use it site wide or on any page where you're using CKEditor (inside a script tag as below, after the editor fields you're using).
<script type="text/javascript">
CKEDITOR.on( 'dialogDefinition', function( ev ) {
// Take the dialog name and its definition from the event data.
var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition;
// Check if the definition is from the dialog we're
// interested on (the Table dialog).
if ( dialogName == 'table' ) {
// Set the tab
var advTab = dialogDefinition.getContents( 'advanced');
// Grab the field
var stylesField = advTab.get('advCSSClasses');
// Set the default value
stylesField['default'] = 'blue_table';
}
});
</script>
This is modified from the CKEditor documentation. The hardest part is working out the IDs and names for all the fields used in the dialogs.
Finally I found the answer. This property is in the dialogadvtab, in the property "advCSSClasses". The thing is that this plugin is inside the core js, I mean the ckeditor.js.
I had to do this :
children :
[
{
id : 'advCSSClasses',
att : 'class',
type : 'text',
label : lang.cssClasses,
'default' : 'blue_table',
setup : setupAdvParams,
commit : commitAdvParams
}
]
The "problem" now is that I had to do it in the ckeditor.js, which is not a good practice. The problem is solved, but not int the best way.

Resources