I have write a function to check whether input in form was checked (in case of mistake in form) - if there exists post array (previously I add: if(isset($_POST)) $tal->post = $_POST;) it search there if input was checked:

   public function isChecked($path, $value) {
           return FALSE;
$path = explode('/', $path); $check = $this->tal->post;
       foreach($path as $part) {
if(is_array($check)) {
               if(isset($check[$part])) {
                   $check = $check[$part];
               } else
                   return FALSE;
if(is_string($check)) {
               return ($check == $value);
} }

Now I have tried to use this function in this way:

<input type="radio" name="account[gender]" value="male" style="width:auto" tal:attributes="checked php:isChecked('account/gender', 'male')"/> Male

But it throws error:

*Fatal error*: Call to undefined function isChecked() in */home/szymon/domains/estender.net/public_html/swiatpracy/application/libraries/PHPTAL.php(564) : eval()'d code* on line *124

*So how can I use this function?

PHPTAL mailing list

Reply via email to