snipt

Ctrl+h for KB shortcuts

Text only

Flash Message

\Session::flash('success', "rows imported successfully.");
$request->session()->flash('danger', "There were $num_errors errors.");
https://snipt.net/embed/ae12ecf7b516246d961ed5eab8cef527/
/raw/ae12ecf7b516246d961ed5eab8cef527/
ae12ecf7b516246d961ed5eab8cef527
text
Text only
3
2024-05-07T23:33:28
True
False
False
Dec 18, 2017 at 11:52 PM
/api/public/snipt/18/
flash-message
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>\Session::flash(&#39;success&#39;, &quot;rows imported successfully.&quot;); </span><span id="L-2"><a name="L-2"></a>$request-&gt;session()-&gt;flash(&#39;danger&#39;, &quot;There were $num_errors errors.&quot;); </span></pre></div> </td></tr></table>
laravel

Text only

mysqldump

mysqldump --routines newsroom > newsroom-alpha-2017-11-15.sql
https://snipt.net/embed/c94d576f20b3f94a10a2afc53ce41291/
/raw/c94d576f20b3f94a10a2afc53ce41291/
c94d576f20b3f94a10a2afc53ce41291
text
Text only
1
2024-05-07T23:38:07
True
False
False
Nov 15, 2017 at 04:45 PM
/api/public/snipt/16/
mysqldump
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>mysqldump --routines newsroom &gt; newsroom-alpha-2017-11-15.sql </span></pre></div> </td></tr></table>
mysql

Text only

Twig Is field empty

1
2
3
{% if content.field_example|render|striptags|trim %}
  <p>field is not empty</p>
{% endif %}
https://snipt.net/embed/c211c83ea29e36f093de8732d330112a/
/raw/c211c83ea29e36f093de8732d330112a/
c211c83ea29e36f093de8732d330112a
text
Text only
3
2024-05-08T16:36:46
True
False
False
Aug 02, 2017 at 05:02 PM
/api/public/snipt/14/
twig-is-field-empty
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>{% if content.field_example|render|striptags|trim %} </span><span id="L-2"><a name="L-2"></a> &lt;p&gt;field is not empty&lt;/p&gt; </span><span id="L-3"><a name="L-3"></a>{% endif %} </span></pre></div> </td></tr></table>
drupal

Text only

Model Array Map for Dropdown

$items = ArrayHelper::map(Standard::find()->all(), 's_id', 'name');
https://snipt.net/embed/9fb5c0940f4f98b23d33217a9866392c/
/raw/9fb5c0940f4f98b23d33217a9866392c/
9fb5c0940f4f98b23d33217a9866392c
text
Text only
1
2024-04-25T19:03:38
True
False
False
Jul 16, 2017 at 03:28 AM
/api/public/snipt/13/
model-array-map-for-dropdown
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$items = ArrayHelper::map(Standard::find()-&gt;all(), &#39;s_id&#39;, &#39;name&#39;); </span></pre></div> </td></tr></table>

Text only

Trim array

$array = array_map('trim', $array);
https://snipt.net/embed/46dbf29d4d32a9b201cb7a7da3c62c57/
/raw/46dbf29d4d32a9b201cb7a7da3c62c57/
46dbf29d4d32a9b201cb7a7da3c62c57
text
Text only
1
2024-04-25T19:12:16
True
False
False
Apr 11, 2017 at 01:50 AM
/api/public/snipt/12/
trim-array
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$array = array_map(&#39;trim&#39;, $array); </span></pre></div> </td></tr></table>
php

Text only

Form Error Summary

<?= $form->errorSummary($model); ?>
https://snipt.net/embed/cf17fa68e973d4b8f30a6fc5e12f156c/
/raw/cf17fa68e973d4b8f30a6fc5e12f156c/
cf17fa68e973d4b8f30a6fc5e12f156c
text
Text only
2
2024-05-03T01:37:48
True
False
False
Feb 05, 2017 at 02:11 AM
/api/public/snipt/10/
form-error-summary
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>&lt;?= $form-&gt;errorSummary($model); ?&gt; </span></pre></div> </td></tr></table>
yii

Text only

Hidden Input

Html::activeHiddenInput($model, 'group_id', ['value' => $group_id])
https://snipt.net/embed/b4ea58d052a21292d2848ddb2022a2b4/
/raw/b4ea58d052a21292d2848ddb2022a2b4/
b4ea58d052a21292d2848ddb2022a2b4
text
Text only
1
2024-05-02T23:10:51
True
False
False
Jan 21, 2017 at 01:01 AM
/api/public/snipt/9/
hidden-input
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>Html::activeHiddenInput($model, &#39;group_id&#39;, [&#39;value&#39; =&gt; $group_id]) </span></pre></div> </td></tr></table>
yii