A2LiX Translation Form labels options - symfony

I'm using KnpLabs/DoctrineBehaviors/Translatable and A2LiX Translation Form to translate my entities in a Symfony application. It works very well. However, when the form is rendered there is a "translations" title that I would like to delete and a "EN [Default]" text on a tab that I would like to change.
In the examples of the doc, there's a "medias" example so I imagine that we can change this text. Moreover, the tabs don't have this [Default] text. So I imagine that's possible to change them.
And this is mine:
Does anybody know how to do it? If we take a look on the form type options we don't see anything concerning the "Translations" label. For the "Default", I can't see where I should search for it.

Default template file is located at vendor/a2lix/translation-form-bundle/A2lix/TranslationFormBundle/Resources/views/default.html.twig. If you want you can specify your own template and set it in config.yml file, like this:
a2lix_translation_form:
....
templating: "#SLCore/includes/translation.html.twig"
More information can be found here.

For the "translations" title, I was able to override it adding a label to the form type just like a normal field. However, it is not possible to use a blank value. I had to use ' ' in order to override the text.
->add('translations', 'a2lix_translations', array(
'label' => ' ', --> this overrides the translations title
'fields' => array(
'name' => array(
'field_type' => 'text',
'label' => 'blabla'
),
'description' => array(
'field_type' => 'textarea',
'label' => 'bleble',
)
)
))
For the "Default" label, I still have no solution.

Related

Adding the Classic Editor to a Gutenberg Block Template

NOTE: Here is a video that helps explain my question: https://drive.google.com/file/d/1c3pS-j8yq75GAwGDrrMMh9X7fDrCKV5R/view?pli=1
I am creating a custom post type that includes a set of blocks as a template. My basic code looks like this:
function register_article_post_type(){
$post_settings = array(
'label' => 'Articles',
'public' => true,
'show_in_rest' => true,
'template_lock' => 'all',
'template' => array(
array( 'core/heading',
array(
'placeholder' => 'Add Categories Heading...',
'className' => 'tour_categories_heading'
)
),
)
);
register_post_type('article', $post_settings);
}
That will create a Custom Post Type called Articles which has a singular Heading block. The thing is, I don't want a heading block, I want the Classic Editor block.
But I can't figure out how to add it. I can easily change the Heading block to a different block (say the paragraph block) if I change array( 'core/heading', to array( 'core/paragraph',.
But when I check the code in Gutenberg for the name of the Classic editor, nothing shows up. As such, I cannot figure out how to add a Classic editor to the custom post type.
Any ideas.
Try core/freeform - should be the slug for the classic editor block

Symfony2 Sonata Admin IvoryCKEditor wrong render for some reason

I am trying to implement IvoryCKEditor Bundle to my SonataAdmin entities and I am witnessing some very strange errors/bugs/mistakes... I dont even know..
So when I want to render a simple textarea field and add some longtext to it I simply do something like this:
/**
* #param FormMapper $formMapper
*/
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
// ->add('id', 'hidden')
->add('name')
->add('contentEn', 'ckeditor', array(
'attr' => array('cols' => '8', 'rows' => '8')))
->add('contentEs', 'ckeditor', array(
'attr' => array('cols' => '8', 'rows' => '8')))
->add('status')
;
}
This works like a charm.. However if I have mapped entities and I want to show its fields I use sonata collection:
->add('translations', 'sonata_type_collection',
array(
'required' => false,
'label' => false,
),
array(
'edit' => 'inline',
'inline' => 'standard',
)
)
And in the mapped entities admin I do this again:
$formMapper
->with('Item Info')
//->add('id')
->add('product_name')
->add('description_for_lbi', 'ckeditor')
->add('short_description', 'ckeditor')
->add('long_description', 'ckeditor')
->add('conditions', 'ckeditor')
->add('language', null, array('required' => true))
->end()
;
Now here is the problem. Its seems the ckeditor form the collection is rendering in a completely different way.
The first example renders an iframe and makes the ckeditor look "clean".
In the collection ckeditor is rendering in a completely different way, no iframes.. And for the editor to show up I have to click on the field first.. And the field has no borders... I really dont know how to explain this.
So I guess my question is, why the ckeditor is rendering completely different when I am using it in a collection. Am I doing something wrong?
If you guys dont understand what I mean I can post some screens...
UPDATE
I thing the problem is here:
'edit' => 'inline',
'inline' => 'standard',
this makes the editor look bad. However if I remove these lines I get error:
Error: Maximum function nesting level of '100' reached, aborting!
This error is when I am trying to edit an object
You are completely right with your edit. inline editing in ckeditor breaks if you have 2 or more instances of the ckeditor config.
My suggestion is to drop inline editing.
For the second part, the error comes from xdebug, which cannot follow your object nesting level because it exceeds this limit.
In order to fix this (which is recommended, as limit = 100 is way too low for symfony2), please see this
article.

How to disable HTML escaping of labels in KnpMenuBundle

I want to render an HTML label like:
$menu->addChild('Dashboard', array(
'route' => 'dashboard',
'label' => '<i class="fa-icon-bar-chart"></i><span class="hidden-tablet"> Dashboard</span></a>',
'extra' => array('safe_label' => true)
)
);
And I've pass the proper option while rendering:
{{ knp_menu_render('WshCmsHtmlBundle:Builder:mainMenu', {'allow_safe_labels': true} ) }}
But my label is still being escaped. What am I doing wrong?
Ok, the answer is!
You set up extra items on menu item not by 'extra' key but by 'extras' key.
So when you setup the item like this:
$menu->addChild('Dashboard', array(
'route' => 'dashboard',
'label' => '<i class="fa-icon-bar-chart"></i><span class="hidden-tablet"> Dashboard</span></a>',
'extras' => array('safe_label' => true)
)
);
it works fine!
There's two steps to achieve this.
1. MenuBuilder
You have to set safe_label to true in extras. Note that you can now write HTML in your label.
$menu->addChild('Home<i><b></b></i>', array(
'route' => 'homepage',
'extras' => array(
'safe_label' => true
),
));
2. Twig
You have to filter the output of knp_menu_render() so that it prints raw HTML (see documentation).
{{ knp_menu_render('main', {'allow_safe_labels': true}) | raw }}
Warning
Please be aware that this may be dangerous. From the documentation:
Use it with caution as it can create some XSS holes in your application if the label is coming from the user.
I used FyodorX's method to add a strong tag. It works like a charm but I must say that the raw filter is not necessary

Drupal 7 customizing the field in add content in admin panel

http://www.photouploads.com/images/customfiel.jpg
i have configure a taxonomy as field of a content type, but i want to replace the checkbox label(work with iphone) to an image which is a image field of that taxonomy(see the photo).
At now i only know to alter node.pages.inc at row 290 by add the code:
$form['product_label'] = array(
'#type' => 'checkboxes',
'#title' => 'Checkboxes Title',
'#title_display' => 'before',
'#default_value' => array(0,2),
'#options' => array(
0 => 'option one',
1 => 'option two',
2 => 'option three',
),
'#theme' => 'testmodule_checkboxes',
);
the product_label is the checkbox name, the above code is to override the current checkbox field. But i think this a not a best way to do..
anyone can provide direction to me? what module or coding can do it?
You shouldn't hack core (except in very few edge cases if you really know what you're doing).
The best place to do this is in your theme. In template.php, you need to use the hook, hook_form_alter() to alter that specific form. You can find out more about the FAPI (form API) here and here.
There's a few ways to alter the form to get the result you want. The easiest way would be to add a unique class for each icon to each form item's attributes array. You can then use CSS to replace the text with the icon (this makes it more accessible as screen readers will still be able to read the text).

Wordpress: How to integrate the media uploader with a custom meta box field?

I'm writing a plugin which creates a custom post_type called "dictionary_entry" which has several custom meta boxes and fields. I'd like to add an addition field which allows the custom post author to upload an audio clip.
I've done some digging and tried the code offered here but I can't get it to work.
I think one possible answer to my question would be the "type" parameter for fields. I've seen "text", "textarea", "time", "color", "radio", etc. but I haven't been able to find a list of all the possibilities. Is it wishful thinking that there might be a field type: "file" or "upload"?
I'm going to skip the code for adding the custom post_type, but here's an example of my code for adding the meta boxes (in case somebody else is trying to use this, remember to use your custom post_type in the 'pages' parameter):
//meta box code
$meta_boxes = array();
$meta_boxes[] = array(
'id' => 'examples', // meta box id, unique per meta box
'title' => 'Examples', // meta box title
'pages' => array('dictionary_entry'), // post types, accept custom post types as well, default is array('post'); optional
'context' => 'normal', // where the meta box appear: normal (default), advanced, side; optional
'priority' => 'high', // order of meta box: high (default), low; optional
'fields' => array( // list of meta fields
array(
'name' => 'Example 1', // field name
'desc' => 'Use it in a sentence? EX: Kanien\'kéha kahrónkha.', // field description, optional
'id' => $prefix . 'example1', // field id, i.e. the meta key
'type' => 'text', // text box
'std' => '', // default value, optional
'validate_func' => 'check_apos' // validate function, created below, inside RW_Meta_Box_Validate class
),
array(
'name' => 'Translation 1', // field name
'desc' => 'What does the sentence mean? EX: I speak Mohawk.', // field description, optional
'id' => $prefix . 'ex_translation1', // field id, i.e. the meta key
'type' => 'text', // text box
'std' => '', // default value, optional
'validate_func' => 'check_apos' // validate function, created below, inside RW_Meta_Box_Validate class
)
)
);
foreach ($meta_boxes as $metabox) {
add_meta_box... //see the codex for add_meta_box()
}
I figured out how to do this by digging into the code found here. If you take a look, you'll recognize parts of my code quoted above. I was originally using this class, but didn't fully realize it. It's a custom class which can be called to add various meta boxes / fields.
It turns out that the "type" parameter I was wondering about actually belongs to this Class (as opposed to the Wordpress API) and that it does allow for a type: 'file' which brings up a default file picker window (not the built-in media uploader). For my purposes this is okay, because I don't need all the slick options.
If you're reading this, you've probably already googled this question and seen a wide variety of posts that partially explain how to do this. For what it's worth, I found this to be the easiest way to add this functionality that ALSO works for custom post_types (without a fair amount of hacking). I hope this is useful to someone else.

Resources