I am new to Yii2 framework and I have strange question. Is it possible to rename GridView column #? I've searched for it in index, layout and etc, but couldn't find where it can be done.
I uploaded the image what I need to rename:
http://imageshack.com/a/img923/3491/ym6Tg0.png
Thank you for the help
I assume this column is SerialColumn. In this case just configure it with different header like:
[
'class' => 'yii\grid\SerialColumn',
'header' => 'Your new name here',
]
Related
I have table column named 'data' that contain JSON data type on my db. Said that my column 'data' contain this:
{"username":"jimmy"; "email":"jimmy#hotmail.com"; "gender":"male"; "age":18}
I want to display 'username' and 'age' attribute to my JSP page. Can someone show me how to do that?
nb: Im using Spring Framework, and Im very new with this technology. Sorry if my question is not specific.
I was wondering, if it is possible to create a OneToMany Relationship in CakePHP3 via a matching Table in the DB.
This is what my DB looks like:
Showcase of DB Schema
This is my Table for ItemA:
$this->belongsTo('ItemB', [
'foreignKey' => 'item_a_id',
'targetForeignKey' => 'item_b_id',
'joinTable' => 'item_a_item_b'
]);
This is my Table for ItemB:
$this->belongsToMany('ItemA', [
'foreignKey' => 'item_b_id',
'targetForeignKey' => 'item_a_id',
'joinTable' => 'item_a_item_b'
]);
However, when I create a Control for ItemA in the template, it still gives me a Multiple Select.
echo $this->Form->control('item_b._ids', ['options' => $item_b, 'empty' => true]);
When I change this Form to Single Select, the selected Object will not be passed. I'm stuck to a Multiple Select :(
Is this the correct implementation of the DB Schema in Cake? Do I have to use the 'through' option? I'm confused...
Edit#1: It works if I configure ItemA with belongsToMany rather than belongsTo. But that would be a ManyToMany Relationship.
Traditionally, this isn't how you'd structure a one-to-many relationship. To enforce this at the DB level you would simply add tbl_item_a.id to the tbl_item_b table like:
tbl_item_b.item_a_id
However, by the sounds of it you know that already. And personally I don't see anything wrong with the setup as you have it, so long as it's documented (for others in the future).
By the sounds of it. The problem you're having isn't with the DB though, it's with the client-side rendering. For which you will want to use the select FormHelper function:
echo $this->Form->select(/*field name*/, /*[options]*/)
I am new in yii2 and i am using wbraganca/yii2-dynamicform widget in my view. My question is that I have to use more than two dynamic form in a single view. For single dynamic widget it works fine while saving from controller but others are saving just the last data of dynamic widget, while inspecting the post data in network array index for others except first dynamic form are not increasing (there index is only zero). Would you please suggest how should I have to do. How can I use multiple dynamic-form widget in single view. Thank you in advance.
I believe the problem must be in your view. You should ensure that each control has a unique name and then loop through the post variables in the controller.
<?= $form->field($modelx, "[{$i}]MyVariableName", ['labelOptions' => ['label' => false]])->textInput(['name' =>'myClassNameHere'."{$block}[$i][MyVariableName]"]) ?>
See the 'name' option in the code above. It gives a unique name to each field. Here the $block variable is a unique code I append to each widgetItem class in the DynamicFormWidget.
If I now look at my POST data, I see something like the following:
myClassNameHere0[0][MyVariableName]:1
myClassNameHere1[0][MyVariableName]:11
If this does not help - post a simply example that you cannot get working and I will have a look at it.
I am using Prestashop 1.6.0.9 and when I have uploaded a CSV file with all the possible fields completed. Then I edited few products in the BackOffice and saved it all. Now, when I click on the export icon, it prompts me to open/save a csv file. However, when I open it - only the ID, Image, Name, Reference, Category, Base Price, Final Price, Quantity and Status fields are exported. I would like to be able to export a similar file to what I imported in. Is it possible?
This is not the prettiest way (I don't PS very well, it's structure, overrides etc.) but look simply into: controllers\admin\AdminProductsController.php.
Near line 150 add new field definition like:
$this->fields_list['custom_field'] = array(
'title' => "Name from lang",
'havingFilter' => false,
'orderby' => false,
'search' => false
);
Hope it's not too late to answering this. :)
Yes. Look into AdminProductsController.php and notice that this is already done for certain fields. Bear in mind that adding this fields will make it also villible in admin panel in Products tab if you don't add some conditional rule for your custom fields What did you mean by that webrama.pl ??
Prestashop By default does not export any more information except than which are display in Product list.
that list are called fields_list in prestashop.
Check controllers/admin/AdminProductsController.php file
Around line 200, you will find how fields_list are generated
with starting of
$this->fields_list = array();
Above that code, you will find some sql queries which will get necessary products data by joining with various tables.
you can add other parameters in select query.
i add wholesale_price in select query to export wholesale_price for all products.
$this->_select .= 'shop.`name` AS `shopname`, a.`wholesale_price`, a.`id_shop_default`, ';
Now this fields_list will display in product listing and will also display in CSV export.
No need to write extra code to add fields_list in export CSV file.
I am redirecting from login page to dashboard page. I want to send teams variable that contain my existing data about the teams. I have tried following but that is not working...
return $this->redirect(array('site/dashboard', ['model' => $model1, 'teams' => $teams]));
model1 is getting sent but not teams...
As arogachev already pointed, the second param is the code, BUT the first param is an array. In order to put some parameters, you need to do something like this:
Yii::$app->response->redirect(['site/dashboard','id' => 1, 'var1' => 'test']);
So for every param you put extra item in the array where the key is the name and the value is the value of the get param.
Cheers!
Change your line to following. Since you have already used array no need for square brackets.
return $this->redirect(array('site/dashboard', 'model' => $model1, 'teams' => $teams));
See official documentation about this method.
The second parameter is status code, so what you are doing is completely wrong.
Passing the variables here does not make any sense because immediately another action starts to load.
You should pass variables to view in action to which you redirect and not where actual redirect happens.