Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extends \Phalcon\Tag #2402

Closed
devate opened this issue May 5, 2014 · 3 comments
Closed

extends \Phalcon\Tag #2402

devate opened this issue May 5, 2014 · 3 comments

Comments

@devate
Copy link

devate commented May 5, 2014

Hi everyone!

First of all thanks for this great framework!!!

I'm trying to extends \Phalcon\Tag class, to override the getValue() method. I want to get value from the POST array for the form fields with names like array (e.g. user[email]).

But when I simply extends the class:

namespace ...;

class Tag extends \Phalcon\Tag {

}

stopped correct working the setDefault() method :( In array _displayValues ​​only have the last assigned value. Also desired function getValue() do not overridden.

This is a bug or am I doing something wrong?

OS: Windows 8 (local server)
php 5.4.13 / 5.5.10
Phalcon 1.3.1

My code examples:

// services.php
...
use MyProject\Library\Tag\Tag;

$di->set('tag', function () {
  $tag = new Tag();
  return $tag;
});

...

// Tag.php

namespace MyProject\Library\Tag;

class Tag extends \Phalcon\Tag
{
  // empty class
}

The next step in the my controller I write this code:

$this->tag->setDefault('field1', 11);
$this->tag->setDefault('field2', 22);
$this->tag->setDefault('field3', 33);

As a result, the first two fields are clean, and the third set the desired value to me.

@ovr
Copy link
Contributor

ovr commented May 6, 2014

Hi
First of all i see code of Tag and Di and didn`t see any error
then i create test for example

<?php

class MyTag extends \Phalcon\Tag
{
        public function getDisplayValues()
        {
                return self::$_displayValues;
        }
}


$tagTest = new MyTag; $tagTest->setDefault('testField1', 11);
var_dump($tagTest->getDisplayValues());

output

zaets28rus@web-server:~/projects/phalcon-1.3.0/build$ php test.php
array(1) {
  'testField1' =>
  int(11)
}

If you past more code about how use it next after setDefault metho, i can help

@devate
Copy link
Author

devate commented May 6, 2014

Insufficiently single call setDefault method for my example. I intentionally write above:

$this->tag->setDefault('field1', 11);
$this->tag->setDefault('field2', 22);
$this->tag->setDefault('field3', 33);

For your example:

$tagTest->setDefault('testField1', 11);
$tagTest->setDefault('testField2', 22);
$tagTest->setDefault('testField3', 33);

output is

array(1) {
  'testField3' =>
  int(33)
}

ovr added a commit to ovr/cphalcon that referenced this issue May 10, 2014
@ovr
Copy link
Contributor

ovr commented May 12, 2014

I fixed this, test latest 1.3.2 branch from ext forlder and closed if its okey

@niden niden closed this as completed in 3605912 Jun 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants