Symfony : Sonata admin custom List Fields URL - symfony

After looking in the documentation :
https://sonata-project.org/bundles/admin/master/doc/reference/field_types.html
I need your help because i want to go a little further in customization and it's not indicated how to do in the documentation.
With this :
->add('hash', "url", array(
'label' => 'HashCode',
'header_style' => 'width: 20%; text-align: center',
'row_align' => 'center',
'route' => array(
'name' => 'cr_whiz_home',
'identifier_parameter_name' => 'id[]'
)
))
I can generate this URL for example:
http://localhost/Symfony/web/app_dev.php/home?id%5B%5D=27
But what I search is to change 27 at the end, because Sonata Admin take automatically id of the entity. I want to take another, the HashCode, i think there is a parameter to change it, but I didn't find it.
Can you help me ? Thank's !

Related

RSS item elements not being not being read by XML Reader

I don't know if i am asking this correctly but plz help me.
I am using Drupal Views to display RSS for my site. I am using the 'Views RSS: Core Elements' module to map the RSS fields with the custom fields added by me in the views. All works well. But a requirement forces me to add custom item elements in the RSS display. I am implementing the hook_views_rss_item_elements() to add custom item elements. When i view the RSS page i get the see the custom items but when i try to read the RSS using a RSS reader, the items are not being read. What am i doing wrong, or am i missing something?
Here is my code to add custom items to the 'SHOW ITEM ELEMENTS : CORE' for RSS display:
function Mymodule_views_rss_item_elements() {
$elements['blogs_title_image'] = array ( 'title' => t('Blogs Title Image'), 'description' => t('Blogs Title Image'), );
$elements['blogs_additional_tags'] = array ( 'title' => t('Blogs Additional Tags'), 'description' => t('Blogs Additional Tags'), );
$elements['blogs_short_desc'] = array ( 'title' => t('Blogs Short Description'), 'description' => t('Blogs Short Description'), );
return $elements;
}
After some research i did manage to find my way out:
I implemented hook_views_rss_namespaces to add a custom namespace and the custom items under the namespace:
function Mymodule_views_rss_namespaces() {
$namespaces['blogs'] = array(
'prefix' => 'xmlns',
'uri' => 'http://base.google.com/ns/1.0',
);
return $namespaces;
}
Note: Use the same 'prefix' and 'uri' as given in the above code or else namespace uri error will arise.

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.

A2LiX Translation Form labels options

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.

How to show fields below checkbox based on "checked" in Redux Framework?

I've downloaded the Redux Framework (using generator). I want some fields to be displayed if a checkbox field is checked (more related fields below checkbox).
I searched online and found some Redux code having checkbox_hide_below field which is not present in the current Redux Framework.
Will I have to do it all by myself or Redux framework provides some option to show/hide fields?
Lead dev of Redux here.
You'd have to do it yourself, however it's really pretty easy.
First, you'd do a get_option to your opt_name before you run your config. Then on the fields you want to make hidden you'd do something like this:
$options = get_options('OPT_NAME');
$field = array(
'id' => 'textarea_id',
'type' => 'textarea',
'hidden' => ( $options['test_value'] == 1 ) ? true : false,
'title' => __( 'Test Hidden Field', 'redux-framework-demo' ),
'desc' => __( 'This field will be set to be hidden if text_value is 1.', 'redux-framework-demo' ),
);
It's pretty strait forward. I hope that helps! You can also apply the hidden argument to sections as well. ;)

Symfony Form: translation of attr

I'm trying to translate help messages that I created on my form using attr array but I can't translate it. Does anybody know how to do it?
This is an example:
->add('facebook_sharing_title', null,
array(
'label' => "establishment.edit.facebooksharingtitle",
'required' => false,
'attr' => array('help' => '70 caractères max. conseillé')
)
)
As you can see, the translation o the label is ok. However, if I do the same for help it doesn't work. I can't find anything about it in the symfony site. I know how to do it on twig but I would like to do it on the form type.

Resources