I've following dropdownlist:
<?= $form->field($model, 'Urlaubsziel')->dropdownList([
1 => 'USA',
2 => 'Mexico',
3 => 'Deutschland',
4 => 'England',
5 => 'Frankreich',],['prompt'=>'Select Country']);?>
How to define a rule to get content of choice in public function rules(){}?
['Urlaubsziel','string'] just will give me the number,not the content
Update your code like below.
<?= $form->field($model, 'Urlaubsziel')->dropdownList([
'USA' => 'USA',
'Mexico' => 'Mexico',
'Deutschland' => 'Deutschland',
'England' => 'England',
'Frankreich' => 'Frankreich',],['prompt'=>'Select
Country']);?>
Related
In a TYPO3 6.2.30 site, I updated RealURL 1.x to 2.2.1.
It works fine, but it is a multilanguage-multidomain site that doesn't require the language prefix after the domain.
Before I had
www.germandomain.ch/seite
www.frenchdomain.ch/page
Now I get
www.germandomain.ch/de/seite
www.frenchdomain.ch/fr/page
The old paths are still working as an alternative though.
How can I omit the parameter from the URL for both languages - is that still possible with RealURL 2?
Below are the relevant configuration snippets. I don't have domain records defined in the backend / pagetree.
'preVars' => array(
array(
'GETvar' => 'L',
'valueMap' => array(
'de' => '0',
'fr' => '1',
),
//'valueDefault' => 'de',
'noMatch' => 'bypass',
),
array(
'GETvar' => 'no_cache',
'valueMap' => array(
'no_cache' => 1,
),
'noMatch' => 'bypass',
),
),
and
$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DOMAINS'] = array(
'encode' => array(
array(
'GETvar' => 'L',
'value' => '',
'ifDifferentToCurrent' => true,
'useConfiguration' => '_DEFAULT',
'urlPrepend' => 'https://www.germandomain.ch',
),
array(
'GETvar' => 'L',
'value' => '0',
'ifDifferentToCurrent' => true,
'useConfiguration' => '_DEFAULT',
'urlPrepend' => 'https://www.germandomain.ch',
),
array(
'GETvar' => 'L',
'value' => '1',
'ifDifferentToCurrent' => true,
'useConfiguration' => '_DEFAULT',
'urlPrepend' => 'https://www.frenchdomain.ch',
),
),
'decode' => array(
'www.germandomain.ch' => array(
'GETvars' => array(
'L' => '0',
),
'useConfiguration' => '_DEFAULT',
),
'www.frenchdomain.ch' => array(
'GETvars' => array(
'L' => '1',
),
'useConfiguration' => '_DEFAULT',
),
),
);
and in TS
config {
sys_language_uid = 0
linkVars = L
language = de
locale_all = de_DE.utf-8
htmlTag_langKey = de
#defaultGetVars.L = 0
}
[globalVar = GP:L = 1]
config {
sys_language_uid = 1
language = fr
locale_all = fr_FR.utf-8
htmlTag_langKey = fr
#defaultGetVars.L = 1
}
[global]
I'm trying to show calendar as inline for CJUIDateTimePicker widget,
<?php widget('CJuiDateTimePicker',array('id'=>'recalldate','name'=>'Time','attribute'=>'eventDate',
'mode'=>'datetime',
'language'=> Yii::app()->request->cookies['language'] == 'en' ? 'en-GB' : Yii::app()->request->cookies['language'],
'options'=>array('changeMonth'=>'true',
'changeYear'=>'true',
'minDate'=>'0',
'yearRange' => '+0:+4',
'showAnim'=>'fold',
'dateFormat'=>'yy-mm-dd',
'value'=>date('yy-mm-dd'),
'theme'=>'redmond',
),
'htmlOptions'=> array('disabled'=>'disabled')
// jquery plugin options
));?>
Please can anyone help me to make as inline calendar as like option (flat) in CJUIDatepicker !!!
flat is a public property in CJuiDatePicker
can be accessed like
'flat' => true
<?php
$this->widget('CJuiDateTimePicker', array('id' => 'recalldate', 'name' => 'Time', 'attribute' => 'eventDate',
'mode' => 'datetime',
'language' => Yii::app()->request->cookies['language'] == 'en' ? 'en-GB' : Yii::app()->request->cookies['language'],
'options' => array('changeMonth' => 'true',
'changeYear' => 'true',
'minDate' => '0',
'yearRange' => '+0:+4',
'showAnim' => 'fold',
'dateFormat' => 'yy-mm-dd',
'value' => date('yy-mm-dd'),
'theme' => 'redmond',
),
'flat' => true,
'htmlOptions' => array('disabled' => 'disabled')
// jquery plugin options
));
?>
I am still learning wordpress and trying to perform a query of posts with WP_Query, meta_query to be precise, the thing is after trying different possible ways and finding out that I can't nest arrays with relations I dont know if the next possible way is to make a sql query directly.
To better explain what I would like to do, the next array hopefully will help:
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'Meta_geo',
'value' => '46',
'compare' => '=',
),
array(
'key' => 'Meta_dest',
'value' => 'si',
'compare' => '=',
),
array(
'relation' => 'OR',
array(
array(
'key' => 'Meta_1',
'value' => '10',
'compare' => '<=',
),
array(
'key' => 'Meta_1',
'value' => '30',
'compare' => '>=',
)
),
array(
'relation' => 'OR',
array(
'key' => 'Meta_1',
'value' => '',
'compare' => '=',
),
array(
'key' => 'Meta_1',
'value' => '',
'compare' => '=',
)
)
)
),
many Thanks for the time, if there are an expertet who can give me a hint I will be grateful.
Sorry for my english.
Based on what you have above the below is the closest your are going to get...
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'Meta_geo',
'value' => '46',
'compare' => '=',
),
array(
'key' => 'Meta_dest',
'value' => 'si',
'compare' => '=',
),
array(
'key' => 'Meta_1',
'value' => array('10','11','12' etc),
'compare' => 'IN',
),
)
This will leave you a little sorting out to do however. This can be done with a loop and as you normally display the results of a query using the loop you can use that.
e.g.
while ( $my_query->have_posts() ) : $my_query->the_post();
$metavalue = get_post_meta($post->ID, 'meta_geo', true);
$metavalue = get_post_meta($post->ID, 'meta_dist', true);// if there are a lot of conds, use get_post_meta($post->ID) to return object of value arrays
if($metavalue == 46 && ): //proceed
//html here!
endif;
endwhile;
This code:
$conditions = array(
'fields' => array(
'User.id'
),
'conditions' => array(
'AND' => array(
'UsersProblem.problem_id' => 38,
'UsersProblem.problem_id' => 34,
),
),
'recursive' => -1
);
$conditions['joins'][] = array(
'table' => 'users_problems',
'alias' => 'UsersProblem',
'type' => 'INNER',
'conditions' => array(
'User.id = UsersProblem.user_id',
));
Is transforming to this SQL query:
SELECT `User`.`id`
FROM `lawyers`.`users`
AS `User`
INNER JOIN `lawyers`.`users_problems`
AS `UsersProblem`
ON (`User`.`id` = `UsersProblem`.`user_id`)
WHERE `UsersProblem`.`problem_id` = 34
Where is AND UsersProblem.problem_id = 38"?
How to create correct find condition to get users with some list of problems? Which are linked as many to many relationship.
Using $this->Problem->find is not possible, beause I need to use 2 joins: users_problems and users_practices. And use for them AND condition, like this:
'AND' => array(
'UsersProblem.problem_id' => 38,
'UsersProblem.problem_id' => 34,
'UsersPractices.practice_id' => 1,
'UsersPractices.practice_id' => 2,
),
You're overwriting 'UsersProblem.problem_id'. Just think about it like the array it is. CakePHP is just using the PHP array structure to do these finds, and that means it follows array rules. But to get around that in cakephp, you're supposed to use a two dimensional array
Like this:
'AND' => array(
array('UsersProblem.problem_id' => 38),
array('UsersProblem.problem_id' => 34)
),
Instead of this:
'AND' => array(
'UsersProblem.problem_id' => 38,
'UsersProblem.problem_id' => 34
),
That way, instead of trying to set the key 'UsersProblem.problem_id' twice, you're making an array that looks like
0 -> array('UsersProblem.problem_id' => 38)
1 -> array('UsersProblem.problem_id' => 34)
And that will work, it's a workaround the CakePHP guys built into the system for this kind of situation.
I think you need to use OR instead of AND:
$conditions = array(
'fields' => array(
'User.id'
),
'conditions' => array(
'OR' => array(
array('UsersProblem.problem_id' => 38),
array('UsersProblem.problem_id' => 34),
),
),
'recursive' => -1
);
You can also roll this up as follows:
$conditions = array(
'fields' => array(
'User.id'
),
'conditions' => array(
'OR' => array(
'UsersProblem.problem_id' => array(34, 38)
),
'recursive' => -1
);
Change your conditions array as shown below:
$options = array(
'fields' => array('User.id'),
'conditions' => array('UsersProblem.problem_id' => array(38,34)),
'recursive' => -1
);
$options['joins'] = array(
array(
'table' => 'users_practices',
'alias' => 'UsersPractices',
'type' => 'INNER',
'conditions' => array(
/CONDITION OF JOIN/
),
array(
'table' => 'users_problems',
'alias' => 'UsersProblem',
'type' => 'INNER',
'conditions' => array(
'User.id = UsersProblem.user_id',
)
);
From User Model:
$this->find('list',$options);
Do not use AND/ OR because they are not optimized for above case.
For reference:
MYSQL OR vs IN performance
and
CakePHP right way to do this (get value from setting's table)
**Try the code for join tables in cakephp.......**
$options = array('joins' => array(
array(
'table' => 'modelname1',
'alias' => 'modelName1',
'type' => 'LEFT',
'foreignKey' => false,
'conditions' => array('modelname1.id = modelname2.mid')
)
),
'fields' => array('modelName1.field1', 'modelName1.field2', 'modelName2.field1', 'modelName2.field2'),
'conditions' => array('modelname.id' => 1, 'modelname2.field1' => ''),
'limit' => 10, 'page' => 1);
$this->modelName2->find($options);
In my project one of the model named types having multiple relation to other models the criteria with part is giving below its like
$criteria->with = array(
'category',
'subCategory',
'accountsSupplierPriceDetails' => array(
'with' => 'serviceLevel'
)
);
the relationship goes like
types - category - relation(1-1)
types - subcategory - relation(1-1)
types - accountsSupplierPriceDetails - relation(1-1)
accountsSupplierPriceDetails - serviceLevel - relation(1-n)
my problem is how to display the names from each table in a grid. the result of (1-n) should be displayed in a dropdownbox. when i try to access the data from column it shows the error Trying to get property of non-object ($data->accountsSupplierPriceDetails->serviceLevel ->name). can anyone please help me.
Thanks in advance.
in my view i create a cgridview with 5 rows in which one row data is populated using dropdownlist.
<div style="width:700px; height:auto;">
<?php
$widget = $this->widget('zii.widgets.grid.CGridView', array(
'id' => 'response-grid',
'dataProvider' => $pickdataset->pickCategorylistingForMain(),
'cssFile' => Yii::app()->baseUrl . '/media/css/gridview.css',
'summaryText' => '',
'ajaxUpdate' => 'response-grid',
'enablePagination' => true,
'pager' => array(
'class' => 'LinkPager',
'cssFile' => false,
'header' => false,
'firstPageLabel' => 'First',
'prevPageLabel' => 'Previous',
'nextPageLabel' => 'Next',
'lastPageLabel' => 'Last',
),
'columns' => array(
array(
'name' => 'id',
'header' => '#',
'value' => '$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)',
),
array(
'type' => 'raw',
'name' => 'categoryExt',
'header' => 'Category',
),
array(
'type' => 'raw',
'header' => 'Sub Category',
'value' => '$data->subCategory->name',
),
array(
'type' => 'raw',
'name' => 'locationExt',
'header' => 'Location',
),
array(
'type' => 'raw',
'header' => 'Name',
'value' => 'CHtml::dropDownList($data->corporate_id."-".$data->category_id."-".$data->sub_category_id."-".$data->location_id,"",popDropBox($data->masterCategoryServiceLevels), array("class" => "listbox"), array("empty" => "Select a Location"))',
),
array(
'type' => 'raw',
'header' => 'Pick',
'value' => 'CHtml::image(Yii::app()->baseUrl . "/media/images/edit_icon.png",$data->corporate_id."-".$data->category_id."-".$data->sub_category_id."-".$data->location_id,array("title" => "Select this Combination"))',
),
),));
function popDropBox($data)
{
$list = array();
foreach ($data as $row)
{
$list[$row->serviceLevel->id] = $row->serviceLevel->name;
}
return $list;
}
?>
</div>
the relation in model is:
'masterCategoryServiceLevels' => array(self::HAS_MANY, 'MasterCategoryServiceLevel', 'category_template_id'),
'corporate' => array(self::BELONGS_TO, 'AccountsCorporate', 'corporate_id'),
'category' => array(self::BELONGS_TO, 'MasterCategory', 'category_id'),
'subCategory' => array(self::BELONGS_TO, 'MasterCategory', 'sub_category_id'),
'location' => array(self::BELONGS_TO, 'MasterLocation', 'location_id'),
the row is
array(
'type' => 'raw',
'header' => 'Name',
'value' => 'CHtml::dropDownList($data->corporate_id."-".$data->category_id."-".$data->sub_category_id."-".$data->location_id,"",popDropBox($data->masterCategoryServiceLevels), array("class" => "listbox"), array("empty" => "Select a Location"))',
),
and i use a function to create dropdown data is
function popDropBox($data)
{
$list = array();
foreach ($data as $row)
{
$list[$row->serviceLevel->id] = $row->serviceLevel->name;
}
return $list;
}
please comment if you have any doubt. i am free to share... have a nice day SO friends... wishes and prayers.