TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   PHPTAL -Trying to get property of non-object while using macros. (http://www.talkphp.com/advanced-php-programming/5799-phptal-trying-get-property-non-object-while-using-macros.html)

ugesh 03-01-2011 05:10 AM

PHPTAL -Trying to get property of non-object while using macros.
 
I am using PHPTAL 1.2.2 Template page is template.tpl

Code:

<form>
        <div tal:repeat="field fields">
                <tal:block tal:define="name repeat/field/key" metal:use-macro="${field/type}" />
        </div>
</form>

<tal:block metal:define-macro="text">
        <label>${field/label}</label><input name="${name}" type="text" value="${field/value}" />
</tal:block>

<tal:block metal:define-macro="select">
        <label>${field/label}</label><select name="${name}">
                <tal:block tal:repeat="value field/valuelist">
                        <option tal:condition="php:field.value != value" value="${value}">${value}</option>

                </tal:block>
        </select>
</tal:block>

And my php page is

Code:

<?php
  require_once 'PHPTAL.php';

  $fields = array(
    'name'  => array('label'=>'Name','type'=>'text','value'=>'Test User'),
    'user'  => array('label'=>'Age','type'=>'select','valuelist'=>array(1,2,3),'value'=>2) ,

    );
  $t = new PHPTAL('tempalte.tpl');
  $t->fields = $fields;
 try {
        echo $t->execute();
    }
    catch (Exception $e){
        echo $e;
    }

?>

I was getting an error in ie as "Trying to get property of non-object in C:\Windows\Temp\tpl_4d6be820_formonline1__HAfMCyjT SQl6RgUTRjXcHA.php on line 24"

But in firefox and chrome it works fine but i view source there was lot of html code in it other than that tag.


All times are GMT. The time now is 07:53 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0