I use in TCA
'uebersetzungen' => [
'exclude' => true,
'label' => 'LLL:EXT:maschinen/Resources/Private/Language/locallang_db.xlf:tx_maschinen_domain_model_maschine.uebersetzungen',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['6:1', 1],
['8:1', 2],
['11:1', 3],
['14:1', 4],
],
'size' => 4,
'maxitems' => 1,
'eval' => ''
],
],
to get the output in fluid template with
<f:switch expression="{maschine.uebersetzungen}">
<f:case value="1">6:1</f:case>
<f:case value="2">8:1</f:case>
<f:case value="3">11:1</f:case>
<f:case value="4">14:1</f:case>
</f:switch>
Now I want to change the renderType to
'renderType' => 'selectSingleBox'
but I have no idea how to get the several values.
I read TYPO3 TCA type select in FLUID?
but I'm not sure whether it's the same problem because I have a different syntax in TCA
Thanks to #Paul Beck I found an answer for my problem.
I can use the solution posted here: TYPO3 TCA type select in FLUID?
But I had to change the line
protected $featuresDecoded;
to
protected $featuresDecoded = [];
Related
I to choose a list-value via the API into Bitrix
CRest::call('lists.element.add',
[ 'IBLOCK_TYPE_ID' => 'lists',
'IBLOCK_ID' => '134',
'ELEMENT_CODE' => 'element'.$entry[134] ,
'FIELDS' => [
'NAME' => 'TEST'.$leadID,
'PROPERTY_1430' => 'YES or NO' ,
]
]
Ho do i set the Value for Protpery_1430? Here "Yes or NO"
There is a screenshot of the values of the Ja (Yes) and (NO):
Some help would be nice :)
Roland
Just pass the list variant identifier; e.g.:
CRest::call('lists.element.add', [
'IBLOCK_TYPE_ID' => 'lists',
'IBLOCK_ID' => '134',
'ELEMENT_CODE' => 'element'.$entry[134] ,
'FIELDS' => [
'NAME' => 'TEST'.$leadID,
'PROPERTY_1430' => 2463, // or 2464
]
];
If you can't use identifiers and need to use values,
use the lists.field.get method and find the identifier by the value from the DISPLAY_VALUES_FORM field.
how to set default item in Select2 on Yii2
The initSelection method of Select2 3.5.x plugin is obsolete/removed.
New initValueText property is been provided with the Select2 widget to
cater to this (e.g. for ajax based loading).
but initValueText dont work!!!
<div class="col-xs-12">
<?php
$categories = [5 => 'test1', 7=> 'test2', 8=> 'test3'];
echo Select2::widget([
'initValueText' => $categories,
'model' => $modelKani,
'name' => 'Kani',
'id' => 'Kani',
'data' => $data,
'showToggleAll' => false,
'options' => [
'placeholder' => 'Insert Item',
'multiple' => true,
'allowClear' => true,
'minimumInputLength' => 2,
'dir' => 'rtl'
],
]);
?>
</div>
result $data:
Array
(
[5] = test1
[7] = test2
[8] = test3
)
Provide model and attribute OR name and value. You have provided model and name so model is ignored and value is set to null.
As for the initValueText - its description states: "the displayed text in the dropdown for the initial value when you do not set or provide data (e.g. using with ajax)". You have provided data.
work with this:
'value' => [5, 10]
item id 5,10 from $data
Doc:
http://demos.krajee.com/widget-details/select2#usage-tags
I have a null-able relation model, and I am using this standard code to retrieve my records:
$this->paginate = [
'contain' => ['Clients']
];
$coupons = $this->paginate($this->Coupons);
I am getting just the records that have client associated.
what is the best practice to make the contain work like OR, and not AND
EDIT: the relationship is seted as the following:
$this->belongsTo('Clients', [
'foreignKey' => 'client_id',
'joinType' => 'INNER'
]);
I have solved it by setting the joinType to LEFT:
$this->belongsTo('Clients', [
'foreignKey' => 'client_id',
'joinType' => 'LEFT'
]);
I would like to use an IN clause in findFirst but it doesn't seem to work?
Expected code, or something similar:
$item = Item::findFirst([
'conditions' => 'categories IN :cats: AND released < :now:',
'order' => 'id ASC',
'bind' => [
'cats' => $this->categories,
'released' => time()
],
]);
I tried using bindTypes but there's no such "list" or "array" type (also, that would get a lot more verbose than expected)...
I know I can do it through the query builder, but I was looking to keep it a bit more idiomatic:
$item = Item::query()
->inWhere('categories', $this->categories)
->andWhere('released < :now:', ['now' => time()])
->orderBy('id ASC')
->limit(1)
->execute()
->getFirst();
You can bind the array and IN clause like this:
$result = ModelName::findFirst([
'conditions' => 'id in ({cats:array})',
'bind' => array('cats' => [3, 5, 8])
]);
Note that the above example will get the first record with id 3. However if you use find() you will get the items with 3, 5 and 8.
More examples in the docs (at the bottom of this section).
I have been trying to fix an issue but to no avail but i am sure i will find a solution here. I am using Kartik 2.0 Select extension to do a multiple select. Fine, all working when inserting into the database but i am unable to retrieve the saved records to be displayed as selected back in the select field.
//I have included the kartik widgets already
use kartik\widgets\Select2;
<label>Desired Specialization(s)</label>
<?= $form->field($spec, 'id')->label(false)->widget(Select2::classname(), [
'data' => $model->getAllSpecializations(),
'options' => ['placeholder' => 'You can choose more than one specialization ...'],
'pluginOptions' => [
'allowClear' => true,
'multiple' => true
],
]);
?>
</div>
Please, your reply will be appreciated. Thanks
I think you need to add the saved values as the initial data? Like so:
'value' => $savedDataArray, // initial value
http://demos.krajee.com/widget-details/select2#usage-tags
After much digging into the code, i found a way on how to display selected database values into a multi-select option using Yii Select2
My Model
public function getCandidateLanguage()
{
$langValues = (new \yii\db\Query())
->select('c.language_id AS id, l.lang_name')
->from('candidate_language c ')
->innerJoin('languages l','c.language_id = l.id')
->where('c.candidate_id='.$this->candidate_id)
->orderBy('c.language_id')
->all();
return \yii\helpers\ArrayHelper::map($langValues,'id','lang_name');
}
My View
use kartik\widgets\Select2;
<?php
//the line below is to fetch the array key of $model->getCandidateLanguage() array
$lang->id = array_keys($model->getCandidateLanguage()); // value to initialize
echo Select2::widget([
'model' => $lang,
'attribute' => 'id',
'data' => $model->getAllLanguages(),
'options' => ['placeholder' => 'Choose multiple languages'],
'pluginOptions' => [
'allowClear' => true,
'multiple' => true,
'tags' => true,
],
]);
?>
Hope it help someone who is facing the same issue.