Define Panel link on Grafana Template - grafana

I am defining panel link on Grafana message template but it is showing up as normal text
enter image description here
But I want something like this on the message.
enter image description here
This is my code: ``{{- define “slack.text” -}}
{{- range .Alerts -}}
{{ if gt (len .Annotations) 0 }}
Summary: {{.Annotations.summary}}
Description: {{.Annotations.description}}
Go to dashboard: {{.DashboardURL}}
{{ end }}
{{ end }}
`{{ end }}```
Can anybody please assist me on this.
Regards,
Zeeshan Khan

Related

Symfony 3 | custom data-prototype displayed two times

I try to display my custom data-prototype for a CollectionType. I followed this answer.
This is what I have:
{{ form_start(form, {'attr': {'class': 'form-horizontal'}}) }}
<div class="form-group">
{{ form_label(form.answers, "Answers", {'label_attr': {'class': 'col-sm-2 control-label'}}) }}
{{ form_errors(form.answers) }}
<div id="mybundle_add_answers"
data-prototype="
{% filter escape %}
{% include 'MyBundle:Form:prototype_answers.html.twig' with {'form': form.answers.vars.prototype} %}
{% endfilter %}">
</div>
Add
</div>
{{ form_rest(form) }}
{{ form_end(form) }}
This is working but, because of form_rest, it displays my data-prototype (mybundle_add_answers) a second time at the end of the form.
It seems that nobody have this problem so What did I do wrong here / forget? I use Symfony 3.0 maybe this is related?
I didn't find a way to do what I wanted with custom data-prototype. I don't know if this is because of Symfony 3 that I have a double widget.
Anyway I did what I wanted with custom collection_widget. If anyone is interested in : https://gist.github.com/cowlby/1294186
And if someone find an answer for this "double" widget problem, I'm still curious to know.
I've had the exact same problem.
After spending a day searching the web for this problem, I ended up simply not using {{ form_rest(form) }} and {{ form_end(form) }}. In my template I added the csrf token manually by using {{ form_widget(form._token) }}, then closed the </form> manually, because in my case that's all form_rest and form_end did.

Symfony submitting individual forms on page with multiple forms

My Symfony project consists of 3 bundles 2 of which provides forms.
I use twig in my view templates.
The first bundle has a view which includes the forms from the other 2 bundles.
My problem is when I attempt to submit either of the 2 included forms, the other form's required field is highlighted - which interferes with either of the forms submissions and data is not committed.
How I can have multiple forms on the same page which don't interfere with each others submission?
Make sure you are not nesting the forms.
Something like this will be fine:
{{ form_start(myForm) }}
{{ form_widget(myForm) }}
{{ form_end(myForm) }}
{{ form_start(anotherForm) }}
{{ form_widget(anotherForm) }}
{{ form_end(anotherForm) }}
but something like this will not:
{{ form_start(myForm) }}
{{ form_widget(myForm) }}
{{ form_start(anotherForm) }}
{{ form_widget(anotherForm) }}
{{ form_end(anotherForm) }}
{{ form_end(myForm) }}

Form error management in symfony 2

Im trying to guess why the form I submit is not valid, since my Entity has no constraints.
I pass to the twig template 'error' => $form->getErrors() but then I have no idea how to show in the twig the error message
Thanks for all
From the docs:
{{ form_errors(form.fooProperrty) }}
And
{{ form_errors(form) }}
If I may guess, your form is not validating because you forgot to render the csrf token, which you can render by doing
{{ form_rest(form) }}

Pyro Group Validation

Background
I want to display a link to the admin area if a user is part of the Administrators group
so in my view code I want to do something like;
{{ if user:group group_name="administrators" }}
Admin Area
{{ endif }}
I found the solution after much messing around but I got it to work;
{{ if user:group=="admin" }}
.....html code
{{ endif }}

Symfony2 Twig Form Widget Array Access

I have a form widget with several choices (many-to-many relationship)
in twig template I can iterate over the checkboxes:
{% for choice in form.downloads %}
{{ form_widget(choice) }} {{ form_label(choice) }}<br />
{% endfor %}
I'd like to acces the choices directly (they should bi formatted end positioned differently)
I tried several syntaxes but the doesn't work
{{ form_widget(form.downloads.0) }} {{ form_label(form.downloads.0) }}<br />
{{ form_widget(form.downloads['0']) }} {{ form_label(form.downloads['0']) }}<br />
{{ form_widget(form.downloads[0]) }} {{ form_label(form.downloads[0]) }}<br />
Do I use the wrong array keys or is array access generally not possible?
Array Access is possible when you're using Twig.
I guess the error you got when you're trying to access the first generated checkbox using
{{ form_widget(form.downloads.0) }} {{ form_label(form.downloads.0) }}<br />
is
Method "0" for object "Symfony\Component\Form\FormView" does not exist in ...
So, you've just to use the child name of your checkbox. You should have in your buildForm something like:
$builder->add('childName', 'anyTypeYouWant', array())
But I guess you're using collection type to generate your checkboxes. In this specific case
{{ form_widget(form.downloads.0) }} {{ form_label(form.downloads.0) }}<br />
should work fine! I already used it to access specific collection fields without customized keys.
You should also use the twig debug extension to check your form.downloads
{% debug form.downloads %}
and if the debug doesn't work, you've to add in your "app/config/config.yml" file
services:
debug.twig.extension:
class: Twig_Extensions_Extension_Debug
tags: [{ name: 'twig.extension' }]