Yii2 clone select 2 widget - yii2

I had used kartik select2 widget for select multiple product, Now want to clone that product select2 in same form.
After clone that product select2 not working. I know problem is unique id but i dont know which id generate problem. after generate clone i had change following attributes value.
id
data-select2-id
data-s2-options
data-krajee-select2
Can anyone help to solve this ?

Related

In testrail API how do I get project_id from case data?

I am trying to add a run with the add_run endpoint, but in my automation code I only have the test cases ids but not the project id (which according the the docs is mandatory).
Right now I am doing:
get all projects with /get_projects
get all cases /get_cases/{project_id}
Then I loop over the cases I get and add the project_id to the case so I could create an add_run with the proper project_id.
This seems like the wrong way to do it.
Anybody has a better solution?
Also is there a way to create a run without a project_id? for example if I have a sanity run that includes cases from many projects.
Any help is appreciated.
You can do the following to get the parent project ID:
get the case by ID and capture value of the suite_id field
get the parent suite by the value of the suite_id field and capture value of the project_id field <--- here you have your project ID and can use it for creating runs.

Magento 1.9, Modify the existing Label under Category

i want to edit/Modify the labels under Category in Magento 1.9 Back-end.
here is the image for your reference.
Those are Labels for Attributes of catalog/category model.
You can edit them via Setup script or directly in the database.
This will give you a complete overview of category attributes:
SELECT * FROM `eav_attribute` WHERE `entity_type_id` = 3
Labels are stored in field frontend_label
I honestly have no clue why someone would want to change those labels.
If your goal is to translate them, then this is a wrong approach. For
translation use locale files instead.

Can't save the data using wbragancia widget yii2 for more than one dynamic form in single view

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.

Woocommerce output variable sku's

I would like to know how to output woocommerce variable sku's. By default woocommerce should be able to change the sku if product variations are clicked but that function doesn't seem to work.
Any help would be grateful.
I know how to output the parent sku
$product->get_sku()
you could use
$available_variations = $product->get_available_variations(); which will create an array of all the variations. Then use a forloop to loop through the array to get each sku.
thanks

CakePHP Invoicing App & Deleting Data From Another Controller/Model

I'm new to CakePHP and I could do with some newbie advice please.
I'm creating an invoicing application and the way I have it set up is with seperate tables (and so Models and Controlllers) for Invoices and Items. The Invoice table holds the data such as 'Invoice Number', 'Date' and 'Client ID' for example, and the Items table stores individual records/items that make up each invoice with 'Quantity', 'Unit Price' etc. The two are associated correctly.
When I call the 'edit' view for Invoices, obviously passing an ID, I retrieve the record and then also loop through the all associated records returned from the Items table to - all works as planned and are retrieved and displayed correctly.
What I want to be able to do from this view though, is to be able to delete individual items from the invoice by clicking on a delete button next to each - ideally with a confirmation box. How would this be acheived exactly? What would be the best method? Would I use a function in the Items controller to do this without leaving the page? How would I call the function in that controller from the Invoice controller/view? Or would another method such as the CakePHP query() function be used for this?
I hope I've explained this setup clearly enough for someone to offer any help and/or advice for which I would be very thankful.
Thanks in advance
The simple way:
In your Invoice/view.ctp
Inside your foreach loop you would do something like this:
//this is loose code since you have not pasted any in your question
<?php echo $this->Html->link('Delete', array('controller'=>'Item', 'action'=>'delete', $item['Item']['id'])); ?>
then create the function in your ItemController.php
function delete($id=NULL){
if($id){
$this->Item->delete($id);
$this->Session->setFlash(__('Invoice item deleted', true));
$this->redirect($this->referer());
}
}