<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[fare checkbox di copilazione obbligatoria con tpl- smarty tags]]></title><description><![CDATA[<p dir="auto">su questa pagina web:<br />
<a href="http://www.lavorohotel.net/post/" rel="nofollow ugc">http://www.lavorohotel.net/post/</a><br />
ho bisogno di rendere i 2 checkbox della privacy obbligatori, ma non so bene usare il codice tpl - smarty..</p>
]]></description><link>https://dev.connect.gt/topic/81211/fare-checkbox-di-copilazione-obbligatoria-con-tpl-smarty-tags</link><generator>RSS for Node</generator><lastBuildDate>Thu, 03 Dec 2026 07:56:02 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/81211.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 01 Sep 2008 15:19:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to fare checkbox di copilazione obbligatoria con tpl- smarty tags on Mon, 01 Sep 2008 20:16:24 GMT]]></title><description><![CDATA[<p dir="auto">Ciao matteoraggi,</p>
<p dir="auto">Per la realizzazione del plugin smarty potresti partire da questo codice e modificarlo secondo le tue esigenze. Sono costretto a fare copia e incolla qui perchè il repository SVN del progetto php5utils su sourceforge sta facendo i capricci.</p>
<p dir="auto">shared.amcheckbox.php</p>
<pre><code class="language-php">&lt;?php
/**
 * @package    Tag Utils
 * @license    http://www.apache.org/licenses/LICENSE-2.0  Apache License 2.0
 * @version    $Id: shared.amcheckbox.php 21 2007-02-26 01:06:26Z ftinti $
 *
 * Required attributes
 *     name
 *     value
 *
 * Optional attributes
 *     multiline    boolean
 **/

function smarty_amcheckbox($params, $smarty)
{
    if ( !in_array('name', array_keys($params)) || empty($params['name']) )
    {
        $smarty-&gt;trigger_error("amcheckbox: missing 'name' parameter");
    }
    $name = $params['name'];

    $bare = "";
    if ( in_array('bare', array_keys($params)) &amp;&amp; !empty($params['bare']) )
    {
        $bare = $params['bare'];
    }

    $multiline = "";
    if ( in_array('multiline', array_keys($params)) &amp;&amp; !empty($params['multiline']) )
    {
        $multiline = $params['multiline'];
    }

    $result = "";
    if ($bare)
    {
        if ($value)
        {
            $result .= '&lt;input type="checkbox" name="' . $name . '" id="' . $name . '" value="true" class="checkbox" checked="checked" /&gt;';
        }
        else
        {
            $result .= '&lt;input type="checkbox" name="' . $name . '" id="' . $name . '" value="true" class="checkbox" /&gt;';
        }
        $result .= '&lt;input type="hidden" name="_' . $name . '" /&gt;';
    }
    else if ($multiline)
    {
        $result .= '&lt;div class="formelement"&gt;'
                 . '&lt;label for="' . $name . '"&gt;' . $name . '&lt;/label&gt;';
        if ($value)
        {
            $result .= '&lt;input type="checkbox" name="' . $name . '" id="' . $name . '" value="true" class="checkbox" checked="checked" /&gt;';
        }
        else
        {
            $result .= '&lt;input type="checkbox" name="' . $name . '" id="' . $name . '" value="true" class="checkbox" /&gt;';
        }
        $result .= '&lt;input type="hidden" name="_' . $name . '" /&gt;'
                 . '&lt;div class="clear"&gt;&lt;!--  --&gt;&lt;/div&gt;&lt;/div&gt;';
    }
    else
    {
        $result  .= '&lt;span class="formelement"&gt;';
        if ($value)
        {
            $result .= '&lt;input type="checkbox" name="' . $name . '" id="' . $name . '" value="true" class="checkbox" checked="checked" /&gt;';
        }
        else
        {
            $result .= '&lt;input type="checkbox" name="' . $name . '" id="' . $name . '" value="true" class="checkbox" /&gt;';
        }
        $result .= '&lt;input type="hidden" name="_' . $name . '" /&gt;';
        $result .= '&lt;span class="chlabel"&gt;' . $path . '&lt;/span&gt;';
        $result .= '&lt;/span&gt;';
    }

    return $result;
}
?&gt;
</code></pre>
<p dir="auto">function.checkbox.php</p>
<pre><code class="language-php">&lt;?php
/**
 * @package    Tag Utils
 * @license    http://www.apache.org/licenses/LICENSE-2.0  Apache License 2.0
 * @version    $Id: function.checkbox.php 21 2007-02-26 01:06:26Z ftinti $
 *
 * Required attributes
 *     name
 *     value
 *
 * Optional attributes
 *     type        string
 *     cssclass    string
 *     style        string
 *     maxlength    integer
 *     readonly    boolean
 *     disabled    string
 **/
    function smarty_function_checkbox($params, $smarty)
    {
        require_once $smarty-&gt;_get_plugin_filepath('shared','amcheckbox');
        $result = smarty_amcheckbox($params, $smarty);
        return $result;
    }
?&gt;
</code></pre>
]]></description><link>https://dev.connect.gt/post/754550</link><guid isPermaLink="true">https://dev.connect.gt/post/754550</guid><dc:creator><![CDATA[mister.jinx]]></dc:creator><pubDate>Mon, 01 Sep 2008 20:16:24 GMT</pubDate></item></channel></rss>