boltforms
boltforms copied to clipboard
contenttype choice label
Hello,
I use contentype choice:
Other parameters are optional.
contenttype_choice:
type: choice
options:
required: false
label: ContentType selection
choices: content
params:
contenttype: pages
label: title
value: slug
limit: 4
sort: title
order: DESC # "ASC" or "DESC"
where:
and: { 'koala': 'bear' }
or: { 'koala': 'dangerous' }
But how can I in the label choose 2 columns?
for example: title and slug
contenttype_choice:
type: choice
options:
required: false
label: ContentType selection
choices: content
params:
contenttype: pages
label: title, slug
Hello, I see that there is no one idea.
My solution is to change in boltforms/src/Choice/ContentTypeResolver.php
protected function getParameterValues(array $params)
{
...
foreach ($records as $record) {
$choices[$record->get($params['label'])] = $record->get($params['value']);
}
...
}
on
foreach ($records as $record) {
if(is_array($params['label'])){
$params_label = '';
foreach ($params['label'] as $label) {
$params_label .= $record->get($label)." ";
}
$choices[$params_label] = $record->get($params['value']);
}else{
$choices[$record->get($params['label'])] = $record->get($params['value']);
}
}
in the configuration file app/config/extensions/boltforms.bolt.yml
clients:
type: choice
options:
required: true
label: Status contact
choices: content
params:
contenttype: clients
label: { 'param1': 'name', 'param2': 'surname' }
value: id
sort: surname
order: ASC
where:
and: { 'status': 'published'}
attr:
class: form-control
exactly
label: { 'param1': 'name', 'param2': 'surname' }
Is that a good solution?