Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

PHP

Add class to field group on Drupal form using hook form alter

1
2
3
4
5
function <your_theme_name>_<your_form_name>_form_alter(&$form, &$form_state) {

  $form['#groups']['<your_field_group_name>']->format_settings['instance_settings']['classes'] .= ' <your_class_name>';
  
 }
https://snipt.net/embed/3e146f6c6284276e2e7a420c0663bbe0/
https://snipt.net/raw/3e146f6c6284276e2e7a420c0663bbe0/
3e146f6c6284276e2e7a420c0663bbe0
php
PHP
5
2016-12-04T00:12:13
True
False
False
Jan 20, 2014 at 09:35 AM
/api/public/snipt/107200/
add-class-to-field-group-on-drupal-form-using-hook-form-alter
<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> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="x">function &lt;your_theme_name&gt;_&lt;your_form_name&gt;_form_alter(&amp;$form, &amp;$form_state) {</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="x"> $form[&#39;#groups&#39;][&#39;&lt;your_field_group_name&gt;&#39;]-&gt;format_settings[&#39;instance_settings&#39;][&#39;classes&#39;] .= &#39; &lt;your_class_name&gt;&#39;;</span> </span><span id="L-4"><a name="L-4"></a><span class="x"> </span> </span><span id="L-5"><a name="L-5"></a><span class="x"> }</span> </span></pre></div> </td></tr></table>
drupal7, form, php

PHP

Get label & input in Joomla 2.5 form

<?php echo $this->form->getLabel('name'); ?>
<?php echo $this->form->getInput('name'); ?>
https://snipt.net/embed/02810fa0a96e153428bb95c6310dfb71/
https://snipt.net/raw/02810fa0a96e153428bb95c6310dfb71/
02810fa0a96e153428bb95c6310dfb71
php
PHP
2
2016-12-03T01:28:15
True
False
False
Dec 04, 2013 at 06:07 AM
/api/public/snipt/98450/
get-label-input-in-joomla-25-form
<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><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">form</span><span class="o">-&gt;</span><span class="na">getLabel</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x"></span> </span><span id="L-2"><a name="L-2"></a><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">form</span><span class="o">-&gt;</span><span class="na">getInput</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
form, input, joomla, label

HTML

Clear default input value on click with pure javascript

<input onfocus="if(this.value == 'Search...') this.value = '';" onblur="if(this.value=='') this.value='Search...';" value="Search...">
https://snipt.net/embed/3265fccfbaaf0605e226ce5c374069ce/
https://snipt.net/raw/3265fccfbaaf0605e226ce5c374069ce/
3265fccfbaaf0605e226ce5c374069ce
html
HTML
1
2016-12-02T10:22:24
True
False
False
/api/public/snipt/98159/
clear-default-input-value-on-click-with-pure-javascript
<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><span class="p">&lt;</span><span class="nt">input</span> <span class="na">onfocus</span><span class="o">=</span><span class="s">&quot;if(this.value == &#39;Search...&#39;) this.value = &#39;&#39;;&quot;</span> <span class="na">onblur</span><span class="o">=</span><span class="s">&quot;if(this.value==&#39;&#39;) this.value=&#39;Search...&#39;;&quot;</span> <span class="na">value</span><span class="o">=</span><span class="s">&quot;Search...&quot;</span><span class="p">&gt;</span> </span></pre></div> </td></tr></table>
form, input, value
Copyrighted, illegal, or inappropriate content? Email [email protected].