How to use the text editor type for a translated type with EasyAdmin 2 and A2lix TranslationFormBundle - easyadmin

In the example below, the SetTranslation entity has a field introduction (type="text") which is displayed in forms using a simple textarea.
How to configure a text field to use the text_editor (only known by EasyAdmin) with a translated field ?
Here is the EasyAdmin 2 config for the Set entiy:
easy_admin:
entities:
Set:
form:
fields:
-
property: translations
type: 'A2lix\TranslationFormBundle\Form\Type\TranslationsType'

The solution is to specify the type with the full path using the type_options and field_type properties:
easy_admin:
entities:
Set:
form:
fields:
-
property: translations
label: ''
type: 'A2lix\TranslationFormBundle\Form\Type\TranslationsType'
type_options:
fields:
introduction:
field_type: 'EasyCorp\Bundle\EasyAdminBundle\Form\Type\TextEditorType'

Related

Add multiple object examples for multipart/form-data in Swagger docs

I hava a POST API using multipart/form-data to send data (requestBody including a binary file, string and object data).
I want to add more than one example for object parameter, but I found using enum is not working:
here is my swagger docs:
post:
tags:
- user
summary: xxx
description: xxx
requestBody:
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/User4'
User4:
type: object
properties:
thisIsAString:
type: string
default: 'testStr'
enum:
- testStr
- testStr2
thisIsAObj:
type: object
default: obj1
enum:
- obj1:
oneOfEx: 'bbb'
- obj2:
oneOfEx2: 'aaa'
file:
type: string
format: binary
What I want is make the eample of thisIsAObj parameter can be changed by a Drop-down list.
Or can I separate the binary file and object data like this?
Thank you.

RichEditor Snippets and Nested Relations Rendering

OctoberCMS Build: 469
PHP Version: 7.3
Database Engine: MySQL
Plugins Installed: Rainlab.Builder, Rainlab.Translate, Inetis.RichEditorSnippets, Rainlab.Pages
Description:
I have followed the tutorial to make List and Form with nested Relations (https://octobercms.com/support/article/ob-21).
I open a model, and inside this model, i have a relation that have many relations like below :
-- Residence
--- Pages
---- Sections
In the "Section" popup, i display a richeditor, with snippets. But when i click on the snippet to open and edit properties, it can't focus the input.
I have search a long time in the source code of all OctoberCms, but i did not find anything.
After many tries, i have found that if in the browser inspector, i delete formPopups, the focus enables.
Here is an example of what i have actually.
Here is an example where i delete the second popup in the browser inspector
Does someone already had this issue ? Is there any fix for ?
EDIT :
Steps to reproduce
To help you to reproduce this,
you need to make 3 models with those fields :
1. Residence - fields.yaml
fields:
name:
label: Residence
span: left
required: 1
type: text
pages:
type: partial
path: pages
home_content:
label: 'Residence Content'
size: large
span: full
type: richeditor
2. Page - fields.yaml
fields:
title:
label: Titre
span: left
required: 1
type: text
sections:
span: full
path: pages_sections
type: partial
3. Section - fields.yaml
fields:
title:
label: Title
span: left
required: 1
type: text
content:
label: Content
size: ''
span: full
required: 1
type: richeditor
And you need to create relations in your models :
Residence.php
public $hasMany = [
'pages' => [
'Author\Plugin\Models\Page'
]
];
Page.php
public $hasMany = [
'sections' => [
'Author\Plugin\Models\Section'
]
];
Then you need to follow the tutorial on Making form with nested relations (https://octobercms.com/support/article/ob-21) to be able to open the relation between Page and Section inside the Residence Form.
Do not hesitate to ask me for more informations,
Best,

Sequelize altering all table fields to snake case

im trying to make a migration to alter all existing table fields to snake case, and future ones to be already written that way.
Up to now i've been doing this with
myTableField = {type: datatype.stmh, field: 'my_table_field'}
thing is i wanna stop doing this and for further upcoming fields i just need them to be set up directly with snake case.
Is there any way of doing this ? or i have to manually run an alter field for each?
Its possible to not rename every field to underscored in the model definition, via the underscored model option.
options.underscored - Converts all camelCased columns to underscored if true
options.underscoredAll - Converts camelCased model names to underscored table names if true
ex:
const User = sequelize.define('User', {
firstname: Sequelize.STRING,
lastname: Sequelize.STRING
},{
underscored:true})
Also on the CLI, we have the option to generate migrations with snakecase
>> sequelize model:generate --name User --attributes firstName:string,lastName:string --underscored
where
--underscored Use snake case for the timestamp's attribute names
But it only does it for the timestamp fields on the migration defs.

How to Specify Checkbox List Values in JTable Jquery Plugin

I am using JTable Jquery plugin, and one of the columns is a checkbox. When creating/editing, this column should show a list of checkboxes of names of locations, which the user can un/check. I've set the type to checkbox as shown below. What else do I need to do to make the checklist show?
location: {
title: 'Location(s)',
width: '50%',
type: 'checkbox',
options: 'http://localhost/proj/locations'
},
The options property returns a list of all the locations. Or how does one specify the list of values to be used? If type was radiobutton, this works alright. When it is checkbox, doesn't work. What else do I need to provide? The docs say one can provide 3 additional options, but these are optional too.
If you want to use checkbox then location field should be Boolean field. Check this link.
Following is example for checkbox:
location: {
title: 'Location(s)',
width: '50%',
type: 'checkbox',
values: { 'false': 'False', 'true': 'True' },
defaultValue: 'true'
},
And you can not use options property with checkbox type. You can only use options property with radiobutton type or dropdown.

Liferay project: Use Facet Search to implement search by category with "logic and"

I want to search out webcontent objects by categoryids. I have defined two groups of category
Marketing:
AA, BB, CC, DD
Country:
America, France, German
I want to find a WebContent which contains [AA, France]. The logic should be 'AA and France'. So I defined a JSON file which is used to load the search condition. But I found my JSON file execute the search with 'AA or France':
{
className: 'com.liferay.portal.kernel.search.facet.MultiValueFacet',
data: {
displayStyle: 'list',
frequencyThreshold: 1,
showAssetCount: true,
values:[AA, France]
},
displayStyle: 'asset_categories',
fieldName: 'assetCategoryIds',
label: 'category',
order: 'OrderHitsDesc',
static: true,
weight: 1.3
}
Can anyone tell me how to implement the logic with 'and'?
First of all it should be 'values': ['AA', 'France'] - allthough some parsers read that invalid JSON (see http://json.org/ for more on this).
If you look at the implementation of MultiValueFacet.doGetFacetClause() you will see:
...
facetQuery.add(termQuery, BooleanClauseOccur.SHOULD);
...
The BooleanClauseOccur.SHOULD expresses the OR logic. If you need an AND logic, you have to implement your own Facet (in an Ext Plugin). You can take MultiValueFacet as blueprint and replace BooleanClauseOccur.SHOULD with BooleanClauseOccur.MUST.
If you think this is something for a feature request - you can create one in the Liferay issues database.

Resources