I am trying to validate null values in a column and i have to update another column based on this validation. My request is,
Say i have Column 'Type' , if column 'Type' has some value in DB means i have to display tick mark in "Valid" column in CGridView. (Valid column is psuedo column)
Column 'Type' has null values means i have to display untick mark in "valid" column.
Please provide any idea over this.
Add New Column in Gridview with
array('name' => 'Status',
'value' => '!empty($data->type) ? "<img />" : "<img tag/>"',
'type' => 'raw'),
you can put your image tag with src in this.
Related
I am doing server side processing of datatables and I want to show extra col merged within a col, for eg. my table looks like:
id
name
age
price
Its all working fine, but I want to display another col in the price col which I am not able to get
For example: I want it to show like
id
name
age
price cur_code
I am trying the following
array(
'db' => 'serv_price',
'dt' => 8,
'formatter' => function( $d, $row ) {
return $d . " " . $row["serv_cur_code"];
}
),
but its not displaying it, how to get cur_code extra field ?
Thanks in Advance.
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'
)
)
);
Is there any way to add a sublist field via a user event script and define its column position? By default the field is added as the last column. It appears you can move form fields around, but can't change sublist column order.
We can able to edit sublist column postion.
But it can be vary based on your records either transaction or suitlet script or any other things just elaborate your question pls.
// For This Example we create a first Field
var field1 = form.addField({
id : 'textfield1',
type : serverWidget.FieldType.TEXT,
label : 'Text'
});
// For This Example we create a first Field
var field2 = form.addField({
id : 'textfield2',
type : serverWidget.FieldType.TEXT,
label : 'Text'
});
form.insertField({
field : field2,
nextfield : 'textfield1'
});
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?
i'm not good with sql, i'm making a CListView for all records with a selected id in column to be displayed on the page.. just for practice, i wanted to add a dropdown that will select another kind of sort (id DESC is already there).
i have a table with columns: id, Name, Project_id, User_id, Assigned, etc...
for now this is my code:
public function actionView($id)
{
$model = $this->loadModel($id);
$criteria = new CDbCriteria(array(
'order'=>'id desc',
'condition'=>'Project_id='.$id
));
$dataProvider = new CActiveDataProvider('Task', array(
'criteria'=>$criteria
));
$this->layout = 'column2';
$this->render('view', array('model'=>$model, 'dataProvider'=>$dataProvider));
}
i'm selecting all records that has the requested project_id, so what i'm trying to do, which i have no clue how to do, is to add another criteria selection on the column "Assigned" the problem is, some of this records has more than 1 single assigned and its being saved as "1,2,5,6". so if i add another selection with assigned 1, it will just show me thoses records that have in assigned "1" and not thoses that have "1,3,5,6".. i was thinking on make a search on string but i dont know how it works on sql (Because i dont know SQL that much)
Try this -
$criteria = new CDbCriteria(array(
'order'=>'id desc',
'condition'=>'Project_id='.$id.' AND find_in_set($assigned, Project_id)'
));
But here $assigned can have only single value i.e. $assigned = 1 or $assigned = 2.
If $assigned = "1,2" where 1,2 itself will be considered as single value and so result will be returned only if the pattern is 1,2.. in the table and not 2,1,...
I hope it gives some idea.
found my solution.. seems like im using SQLite and SQLite does not support find_in_set(), instead. i would have to use (',' || Assigned || ',') LIKE '%,1,%'. like this..
$criteria = new CDbCriteria(array(
'order'=>'id desc',
'condition'=>'Project_id='.$id.' AND ("," || Assigned || ",") LIKE "%,5,%"'
));