Cphalcon: PHP7+Phalcon 3.1.2 Setting variables to the view in a controller does not take effect.

Created on 10 Jun 2017  路  2Comments  路  Source: phalcon/cphalcon

Questions should go to https://forum.phalconphp.com
Documentation issues should go to https://github.com/phalcon/docs/issues

Expected and Actual Behavior

Describe what you are trying to achieve and what goes wrong.
Setting variables to the view in a controller does not take effect.

```
$testKey = "testKey";
$this->view->testkey = $testKey;

in volt template file:
      {{ testKey }} will get empty value.

But:
`        $this->view->setVar("testKey", $testKey);`

This method is correct. The view will get previous value assigned in controller.

> Provide output if related. Provide coredump if any. Use 
```php
// paste output here

Provide minimal script to reproduce the issue

// paste code

Details

  • Phalcon version: (php --ri phalcon)
    phalcon

Web framework delivered as a C-extension for PHP
phalcon => enabled
Author => Phalcon Team and contributors
Version => 3.1.2
Build Date => Jun 4 2017 17:28:45
Powered by Zephir => Version 0.9.7-1fae5e50ac

Directive => Local Value => Master Value
phalcon.db.escape_identifiers => On => On
phalcon.db.force_casting => Off => Off
phalcon.orm.events => On => On
phalcon.orm.virtual_foreign_keys => On => On
phalcon.orm.column_renaming => On => On
phalcon.orm.not_null_validations => On => On
phalcon.orm.exception_on_failed_save => Off => Off
phalcon.orm.enable_literals => On => On
phalcon.orm.late_state_binding => Off => Off
phalcon.orm.enable_implicit_joins => On => On
phalcon.orm.cast_on_hydrate => Off => Off
phalcon.orm.ignore_unknown_columns => Off => Off

  • PHP Version: (php -v)

PHP 7.0.19 (cli) (built: Jun 4 2017 17:25:39) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Xdebug v2.5.4, Copyright (c) 2002-2017, by Derick Rethans
with Zend OPcache v7.0.19, Copyright (c) 1999-2017, by Zend Technologies

  • Operating System:
    "Ubuntu 16.04.2 LTS"
  • Installation type: Compiling from source || installing via package manager
    Phalcon installed via install.sh script.
  • Zephir version (if any):

  • Server: Nginx | Apache | Other
    Nginx

  • Other related info (Database, table schema):

Most helpful comment

$this->view->testkey must be $this->view->testKey for {{ testKey }}

All 2 comments

$this->view->testkey must be $this->view->testKey for {{ testKey }}

Oh...I'm really sorry making such a silly mistake.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

richmilns picture richmilns  路  3Comments

EquaI1ty picture EquaI1ty  路  3Comments

bestirani2 picture bestirani2  路  3Comments

ismail0234 picture ismail0234  路  3Comments

kkstun picture kkstun  路  3Comments