public static function dropDownList($name,$select,$data,$htmlOptions=array())
In this above syntax i not able to understand $select field.In yii tutorial(http://www.yiiframework.com/doc/api/1.1/CHtml#dropDownList-detail) they are said $select is selected item.but i cant able to understand.can anyone give clear example with explanation.
Let's say you have a dropdown list with the following values
$daysOfTheWeek = array(
0 => 'Monday',
1 => 'Tuesday',
2 => 'Wednesday'
3 => 'Thursday'
);
Then if you want at the beging that the selected value is Tuesday then in the widget you will put:
CHtml::dropDownList('daysOfTheWeek', '0', $daysOfTheWeek);
This is usefull when you want to edit something, since it already has an assigned value you can put it by default so the dropdown will be already filled with the previous value.
Related
I have a cpt "members".
In a post I can select multiple members (object) via ACF in the specific post.
Now I want say: Please give me all posts where a member (e.g. nr. 76) ist marked in the post.
I try the whole day, and have no idea.
It's possible if i change the acf field to one number to get the correct posts, but Its important that I can select multiple members.
Thanks for helping!
Finally got it :-)
$args = array(
'post_type'=>'post',
'numberposts'=> -1,
'meta_query' => array(
array(
'key' => 'members',
'value' => '76', //example
'compare'=>'LIKE'
)
)
);
When trying to execute an XML request to Infusionsoft, I cannot get the dataservice.query to function properly. Basically, I have a list of "valid" tags that I would like to find out if a contact has applied to them. In the documentation it says
queryData: struct (required)
A struct containing query data. The key is the field to search on, and the value is the data to look for. % is the wild card operator and all searches are case insensitive. Below is a list of operations you can do.
Greater Than ex: LastUpdated => '~>~ 2017-01-01 00:00:00'
Greater Than or Equal to ex: LastUpdated => '~>=~ 2017-01-01 00:00:00'
Less Than ex: LastUpdated => '~<~ 2017-01-01 00:00:00'
Less Than or Equal to ex: LastUpdated => '~<=~ 2017-01-01 00:00:00'
Not Equal to ex: Id => '~<>~123'
Is Null ex: FirstName => '~null~'
IN statement ex: Id => [1,2,3,4]**
*The raw xml, will need be html encoded for '>' and '<'
**IN statements only work on Id fields and are limited to 1000 ids
But, I cannot get that in statement to work even through postman...
<member><name>GroupID</name>
<value><int>in [165,163]</int></value>
</member>
Obviously that code isn't going to work, but I hope you can see what I am trying to accomplish.
There just isn't clear documentation on how to do this OUTSIDE of PHP SDK. Any help would be appreciated.
I know this is a little old, but the correct formatting should be [165,163]. You should not include the actual work in.
I have a registration form and i added 3 select input for date of birth user.
Here the HTML code.
http://hastebin.com/unoxogipuj.vbs
In my RegisterController.php I've added following rules for validation.
'day' => 'required|in:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31',
'month' => 'required|in:1,2,3,4,5,6,7,8,9,10,11,12',
'year' => 'required|in:2003,2002,2001,2000,1999,1998,1997,1996,1995,1994,1993,1992',
Again in my RegisterController.php for user creation i added field for store the date in my database
'dob' => $data['day' . 'month' . 'year']
In the User Model I've added in protected fillable my field but this don't work.
You can use between:min,max here.
https://laravel.com/docs/5.3/validation#rule-between
Like:
'day' => 'required|between:1,31',
'month' => 'required|between:1,12',
'year' => 'required|between:2003,1992'
And can you please show more controller and model code?
As an follow up idea to solve my "sort product collection by sub-category" problem explained in my question sorting collections by subcategory, an attribute and by productname I had the idea to add a AS expression to the selected fields of the collection.
What I want to achieve (SQL-wise) is something like this:
SELECT field1, 'some string' as 'category_name' FROM ...
So I thought I could use the addExpressionFieldToSelect in the method chain to dynamically add the category name string to the products collection.
For that have the following:
// ...
$_products = Mage::getModel('catalog/product')
->getCollection()
->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
->addAttributeToSelect('*')
->addExpressionFieldToSelect('\'some category name\'', 'AS', 'category_name')
->addAttributeToFilter('status', 1)
->addAttributeToFilter('visibility', 4)
->addAttributeToFilter('is_saleable', array('like' => '1'))
->addAttributeToFilter('category_id', $_subcategory_finset_ids)
->addAttributeToSort('ws_geschmack', 'ASC')
->addAttributeToSort('name', 'ASC');
// ...
But with that I get an error:
Fatal error: Call to undefined method Mage_Catalog_Model_Resource_Product_Collection::addExpressionFieldToSelect() ...
Short explanation: In fact I am not able to sort product collections by sub-category (string) I first query all child categories of a parent category (ordered) and within a loop I query all products of these child categories (down to the deepest level) to get products sublists of each subcategory and sub-sub categories. To fully understand my problem, please refer to my question mentioned above.
It is just a try, I do not know if all this is really working. As a hack for now I just try to come a little closer with that AS expression field holding the category name of the outer loop. I then could merge these collections and would have a final products collection.
If there is a more simple way, please let me know.
Any help is greatly appreciated!!
Update
Instead of using addExpressionFieldToSelect it is possible to use this:
$_products->getSelect()
->columns(
array(
'category_name' => new Zend_Db_Expr(
'some string')
)
);
As stated above in my update, I solved the problem by using:
$_products->getSelect()
->columns(
array(
'category_name' => new Zend_Db_Expr('some string')
)
);
In fact, simple solution!
I've tried defaultDate="" property but it doesn't show even if I gave some value to the date picker?
Here's my datepicker code:
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model'=>$model,
'attribute'=>'date_healed',
'value'=>$date_healed,
'name'=>'date_healed'.$i,
// additional javascript options for the date picker plugin
'options'=>array(
//'autoSize'=>true,
'defaultDate'=>"",
'changeMonth'=>'true',
'changeYear'=>'true',
'yearRange'=>Yii::app()->params['YearRange'],
),
'htmlOptions'=>array('size'=>'10')
));
Make sure you delete default value from database table
if you see the table structure ... if you see like this, then remove '0000-00-00'
....
`date_healed` date NULL DEFAULT '0000-00-00',
....
should be...
....
`date_healed` date NULL,
....