Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static mode is not working for widget #25

Closed
xoco70 opened this issue Nov 18, 2020 · 4 comments
Closed

static mode is not working for widget #25

xoco70 opened this issue Nov 18, 2020 · 4 comments

Comments

@xoco70
Copy link
Contributor

xoco70 commented Nov 18, 2020

Hi,

When adding a widget in static mode, with 5 params, it says it wants 0 or 4 :

if ($argumentsCount !== 0 && $argumentsCount !== 4) {

            throw new RuntimeException('Invalid number of arguments, expected: { int $x, int $y, int $width, int $height } or none.');

        }

so static mode is not working.

How to pass options to a widget ???

@cord
Copy link
Contributor

cord commented Nov 18, 2020

->withMeta($options)

@xoco70
Copy link
Contributor Author

xoco70 commented Nov 18, 2020

Ah, thanks for the tip, @cord

I couldn't make it :(

Here is how I am doing it :

public function widgets(): array
    {
        $widget = new ConsumedSolarEnergyValue(0, 0, 2, 1);
        $options = [
            "prefix" => null,
            "suffix" => "kWh",
            "decimal" => "2",
            "no_current_data" => "N\/A",
            "labels" => [
                "No Prior Data" => "Aucune donn\u00e9e plus ancienne",
                "No Current Data" => "Aucune donn\u00e9e",
                "No Increase" => "Pas d\u2019augmentation",
                "Increase" => "Augmentation",
                "Decrease" => "Diminution",
                "Previous Value" => "Previous value:"
            ],
            "widget_title" => "Energie r\u00e9seau consomm\u00e9e",
            "widget_help" => null
        ];
        $widget->withMeta(['options' => $options]);
        return [
            $widget,
        ];
    }

If I change it to

$widget->withMeta(['optionsXXX' => $options]);,

I can see the optionsXXX value when checking /nova-vendor/nova-dashboard/tableau-de-bord.

but when I use options, it seems to be overwritting the $options variable with null values.

Do you have an example you already did ?

@xoco70
Copy link
Contributor Author

xoco70 commented Nov 19, 2020

mmm. Still can't find it. I think withMeta may not be the problem, it is just overwritten by empty defaults, and I can't find to see why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants