uicomponent – Add link and to backend modal and pass values to controller

I have a PrintButton on the backend which links me to a controller. This button should open a modal with a radioset of buttons and pass this to the controller.

The xml of the backend page:

<argument name="data" xsi:type="array">
    <item name="buttons" xsi:type="array">
        <item name="back" xsi:type="array">
            <item name="name" xsi:type="string">back</item>
            <item name="label" xsi:type="string" translate="true">Back</item>
            <item name="class" xsi:type="string">back</item>
            <item name="url" xsi:type="string">*/*/index</item>
        <item name="delete" xsi:type="string">VendorModuleBlockAdminhtmlResultCodeDeleteButton</item>
        <item name="export" xsi:type="string">VendorModuleBlockAdminhtmlResultCodeExportButton</item>
        // This is my button /
        <item name="print" xsi:type="string">VendorModuleBlockAdminhtmlResultCodePrintButton</item>

My PrintButton.php:

class PrintButton extends GenericButton implements ButtonProviderInterface
     * Get button data
     * @return array
    public function getButtonData()
        $data = ();
        $codeSetId = $this->getCodeSetId();

        if ($codeSetId && $this->canRender('print')) {
            $data = (
                'label' => __('Print'),
                'id' => 'print',
                'class' => 'primary print',
                'data_attribute' => (
                    'mage-init' => (
                        'Magento_Ui/js/form/button-adapter' => (
                            'actions' => (
                                    'targetName' => 'vendor_resultcode_codes_grid.vendos_resultcode_codes_grid.print_modal',
                                    'actionName' => 'toggleModal',
                                    'params' => (
                'on_click' => '',
                'sort_order' => 10,
        return $data;

Before on_click looked like this:

'on_click' => 'setLocation('' . $this->getPrintUrl($codeSetId) . '')',

The Modal in my xml:

<modal name="print_modal">
                <option name="buttons" xsi:type="array">
                    <item name="0" xsi:type="array">
                        <item name="text" xsi:type="string">Done</item>
                        <item name="class" xsi:type="string">action-primary</item>
                        <item name="actions" xsi:type="array">
                            <item name="0" xsi:type="array">
                                <item name="targetName" xsi:type="string">${ $.name }</item>
                                <item name="actionName" xsi:type="string">actionDone</item>
                <option name="title" translate="true" xsi:type="string">Choose how often to print each label</option>
        <fieldset name="general" sortOrder="10">
            <radioset name="radioset_print">
                    <label translate="true">Choose how often to print each label</label>
                        <rule name="required-entry" xsi:type="boolean">true</rule>
                        <option name="0" xsi:type="array">
                            <item name="value" xsi:type="number">1</item>
                            <item name="label" xsi:type="string">1x</item>
                        <option name="1" xsi:type="array">
                            <item name="value" xsi:type="number">2</item>
                            <item name="label" xsi:type="string">2x</item>
                        <option name="2" xsi:type="array">
                            <item name="value" xsi:type="number">3</item>
                            <item name="label" xsi:type="string">3x</item>
                        <option name="3" xsi:type="array">
                            <item name="value" xsi:type="number">4</item>
                            <item name="label" xsi:type="string">4x</item>
                        <option name="4" xsi:type="array">
                            <item name="value" xsi:type="number">5</item>
                            <item name="label" xsi:type="string">5x</item>

So how exactly can I pass my values to the controller and also make my “Done” button execute the previous on_click value?

python – Are set values faster than using variables

Using variables more convenient when values like MARGIN need to be changed

pygame.draw.line(screen, WHITE, (x - MARGIN, y - MARGIN), (x + TILESIZE, y - MARGIN), MARGIN)
pygame.draw.line(screen, WHITE, (x - MARGIN, y + TILESIZE), (x + TILESIZE, y + TILESIZE), MARGIN)
pygame.draw.line(screen, WHITE, (x - MARGIN, y - MARGIN), (x - MARGIN, y + TILESIZE), MARGIN)
pygame.draw.line(screen, WHITE, (x + TILESIZE, y - MARGIN), (x + TILESIZE, y + TILESIZE), MARGIN)

But if they were already set, would it be faster to do:

pygame.draw.line(screen, WHITE, (x - 1, y - 1), (x + 20, y - 1), 1)#Top
pygame.draw.line(screen, WHITE, (x - 1, y + 20), (x + 20, y + 20), 1)#Bottom
pygame.draw.line(screen, WHITE, (x - 1, y - 1), (x - 1, y + 20), 1)#Left
pygame.draw.line(screen, WHITE, (x + 20, y - 1), (x + 20, y + 20), 1)#Right

unable to copy WooCommerce checkout state field values from billing to shipping, or vice versa

I’m trying to modify the WooCommerce checkout display so that:

  1. Both field columns are open and expanded
  2. There is a checkbox under shipping address, which upon clicking, copies data over from the billing fields to the shipping fields.

I’ve got that part set up, but though the state data is copied over from one area to another, upon trying to place order, the error message of “Shipping State is a required field.
No shipping method has been selected.” is displayed.

I’m presuming that the data upon manually using the state select field is being recorded somewhere other than the DOM, which is why it’s not working?

Here’s my jQuery code that’s doing the copying:

<script type="text/javascript">
$("#ship-to-billing-address-checkbox").on("click", function(){
    // if (this.checked) {

If you want to see it in action, go to https://stage.chilwellness.com/checkout/?add-to-cart=12105. Enter your info in billing, click the checkbox, then you’ll see that though the state field seems entered, the label is still the color red, indicating that it’s needing data still.

list manipulation – Substituting values from an association thread into a table of expressions

I have asked a question here. Yet I am trying to do the same procedure with AssociationThread Suppose I have the following function which is a normal distribution:

(Sigma) = 4.75;
(Mu) = 3.96;
f(x_) := 1/((Sigma)*Sqrt(2 (Pi)))
   Exp(-(1/2) ((x - (Mu))/(Sigma))^2)

and I have the following list:

cases={2, 8, 9, 13, 14, 15, 16, 17, 18, 19, 20, 22, 23, 28, 30, 34, 37, 43, 
55, 59, 90, 129, 180, 229, 276, 349, 396, 446, 571, 794, 1152, 1572, 
1965, 2282, 2679, 3225, 3905, 4814, 5745, 6826, 7860, 9068, 11084, 
13106, 15368, 17975, 20633, 23005, 25443, 28956, 32719, 36802, 40814, 
44865, 48188, 51221, 55551, 60024, 64256, 68271, 71776, 74771, 77456, 
80762, 84179, 87782, 91219, 94644, 97217, 99301, 102374, 105368, 
108129, 110897, 113666, 115476, 116880, 119100, 121384, 123731, 
125852, 127804, 129042, 130001, 131623, 133233, 134671, 136117, 
137141, 138034, 138759, 140004, 141102, 142177, 143070, 143979, 
144612, 145249, 146191, 147209, 148030, 148778, 149483, 149937, 
150322, 150832, 151375, 151917, 152371, 152806, 153147, 153452, 
153900, 154379, 154821, 155135, 155457, 155666, 155872, 156171, 
156481, 156846, 157120, 157391, 157652, 157860, 158139, 158447, 
158735, 158982, 159217, 159367, 159486, 159687, 159891, 160059, 
160209, 160325, 160382, 160391, 160391}
Prob = Table(NIntegrate(f(x), {x, i, i + 1}), {i, 1, 141});
(Alpha) = 
  AssociationThread(Table(Subscript(t, i), {i, 1, 141}) -> cases);
(Beta) = 
  AssociationThread(Table(Subscript(c, i), {i, 1, 141}) -> cases);
(Gamma) = 
  AssociationThread(Table(Subscript(p, i), {i, 1, 141}) -> Prob);

I want to replace the values from alpha, beta and gamma accordingly into the following table:

Table(1/(Subscript(c, j) - (1 - (Theta)) Subscript(t, j))
    n) (Subscript(c, n) - (1 - (Theta)) Subscript(t, n)), {n, 2, 
    141}), {j, 1, 140})

I wonder how one can achieve this?

ordinary differential equations – $lambda$ values of $y”-(frac{1}{4}+frac{lambda}{x}).y=0$ such that there is a non trivial solution

What are the $lambda$ values such that $$; y”-(frac{1}{4}+frac{lambda}{x}).y=0 ;;; 0<x<infty$$ $$ y(0)=0 ; ; ; lim_{xrightarrowinfty}y(x)=0$$
have a non trivial solution.

Trying to use the Frobenius method, I found that $; (s^2+s-lambda).a_1=0;$ and the recurrence relation $; a_k=frac{-1}{k.(k-1)}.(frac{1}{4}.a_{k-2}+lambda.a_{k-1});$. These results that I got are correct ? How can I get the answer by these results ?

c# – Incrementing Values inside an if statement

I found out that I can increase the value of a variable inside an if statement like so:

int limit = 100;
int nrCopies = 2;
int maxValue = 100;
for(int i = 0; i < limit; ++i)
    if((nTotal += (nrCopies)) > maxValue)

This works, and I became acostumed to do this, but I want to know if it is a good practice to do so, since I don’t want to get bad habits unnecessarily

Google Sheets formula to find rows with matching values, looking up in multiple columns

What would be the Google Sheets formula to search for a matching value in a range that goes across multiple rows an columns? For example I need to search the entire range H:P (all rows and columns) and find the cells with a matching value, if any. Ultimately in this case I need just a list of the row numbers where a matching cell is found. In the screenshot there are two matches highlighted in green. There is a match on O2, and on M3. So in this case I need a result like “2,3”.

I have tried various things for several hours with no luck. Most examples of formulas that I could find and understand are about looking up in either a single column, or row.

Any help appreciated! Thank you!

range to be searched

syntax – Create a list of coordinates given a list of x values and a function

I have a function and $x$-values as a list. How do I construct a list with coordinates $(x_i,y(x_i))$, $i=1, 2, …$

y(x_):= 2x
x = { -3, 0, 4, 5}

which should be made into

{ {-3,-6}, {0,0}, {4,8}, {5,10} }

Is there some compact command for this?
The following works but is perhaps not optimal;

Table({x((i)), y(x)((i))}, {i, 1, Length(x)})

feeds – Single Image field importing as Multiple Values

I’ve created a CSV feed via Views Export that exports out data for a content type. I’m then using Feeds to import that onto another Drupal site.

Everything except the images are working, when I run import it’s stating

Failed importing 2 RSS Item items.

The content failed to validate with the following errors:
Image (field_image): Image: this field cannot hold more than 1 values.
Please check your mappings.

The field in question on Site A has a single limited value of 1, and checking the CSV export it’s only showing one value, the absolute url of the image on Site A.

I’ve attempted to use Feeds Tamper and use all the plugins I can think of to fix this, but due to my freshness to Feeds and Feeds Tamper I’m not sure if this is a bug or misconfig on my part. Everything else is importing as expected onto Site B.

How can I get the import running successfully?

rest – Is it a good practice to have an endpoint URL with parameter accepting different type of values?

To add to what Ewan has said, since HTTP already has “stringly” typed parameters, so it can be impossible to parse the parameters correctly. You should aim for precision in being able to express your intent. You will already have a lot of other factors to deal with, but you don’t want to have design ambiguity as part of it.

Ewan gives the counter-example of having both siteId: 1 and siteCode: “1”. That is bad, since you will eventually run into that, and it can become more and more complex. Avoiding that will make your life easier. And even if you don’t think you will have that problem, you must have logic to determine the intent of the client, but that is backwards– the client should determine their intent and be able to express it unambiguously to you by selecting an endpoint.

A single client will almost always pick one endpoint, so removing as many edge cases from that endpoint as possible will simplify usage for your clients as well. A client would rarely want to pass a siteId and siteCode to the same endpoint.

Function overloading in normal code works because of the type encoding of parameters, when that type information does not exist, you need to have another way of expressing it.

Documenting two separate endpoints will also be easier for your users. They will usually already know what sort of data they have access to and can pass in to you. Having a clearly separated set of two endpoints with exact specifications will allow them to find the one they are looking for and use that. It will be clearly documented and straightforward to use, instead of trying to understand the type differentiation between two.