Giter Site home page Giter Site logo

Nette 2.4 compatibility about forms HOT 7 CLOSED

JanTvrdik avatar JanTvrdik commented on July 16, 2024
Nette 2.4 compatibility

from forms.

Comments (7)

hrach avatar hrach commented on July 16, 2024

Well, this should be imo reported into the Nette issue tracker. I can't see why totally standard call should be "BC breaked".

$me->addMacro('label', array($me, 'macroLabel'), array($me, 'macroLabelEnd'));

from forms.

hrach avatar hrach commented on July 16, 2024

@dg isn't possible to fix this on Nette side?

from forms.

hrach avatar hrach commented on July 16, 2024

If I remember it corectly, addMacro was forpushed,so the impl. may be a mistake.

from forms.

dg avatar dg commented on July 16, 2024

It should be compatible, i.e. flag is optional. Is your macro registered before/after/instead of default macros?

ie. this seems https://github.com/nextras/forms/blob/master/src/DI/FormsExtension.php#L30 that macros are registered each time template is rendered, not only when is compiled.

from forms.

FilipNovy avatar FilipNovy commented on July 16, 2024

@hrach Check dg commet. Maybe it is solution. Now I am stuck on "Incompatible flags for macro label".

from forms.

hrach avatar hrach commented on July 16, 2024

Will try asap!

from forms.

trejjam avatar trejjam commented on July 16, 2024

I must test it but it is looks like FormsExtension register Macro different way then LatteExtension:

If is loaded FormsExtension and in config.neon is latte.macros: [Nextras\Forms\Bridges\Latte\Macros\BS3InputMacros]

public function create()
    {
        $service = new Latte\Engine;
        $service->setTempDirectory('/var/www/app/../temp/cache/latte');
        $service->setAutoRefresh(TRUE);
        $service->setContentType('html');
        Nette\Utils\Html::$xhtml = FALSE;
//by Latte
        $service->onCompile[] = function ($engine) { Nextras\Forms\Bridges\Latte\Macros\BS3InputMacros::install($engine->getCompiler()); };
//by Nextras
        Nextras\Forms\Bridges\Latte\Macros\BS3InputMacros::install($service->getCompiler());
        return $service;
    }

I found this two possibility to solve this, both edit FormExtension::beforeCompile, but I do not know which is better/right. Both do the same, but different way:

public function beforeCompile()
    {
        parent::beforeCompile();

        $latteExtensionArray = $this->compiler->getExtensions(Nette\Bridges\ApplicationDI\LatteExtension::class);
        /** @var Nette\Bridges\ApplicationDI\LatteExtension $latteExtension */
        $latteExtension = reset($latteExtensionArray);
        $latteExtension->addMacro('Nextras\Forms\Bridges\Latte\Macros\BS3InputMacros::install');
    }
public function beforeCompile()
    {
        parent::beforeCompile();

        $builder = $this->getContainerBuilder();

        $builder->getDefinition('nette.latteFactory')
            ->addSetup('?->onCompile[] = function ($engine) { Nextras\Forms\Bridges\Latte\Macros\BS3InputMacros::install($engine->getCompiler());};', ['@self']);
    }

I send PR if you say which you prefer, one use knowledge of LatteExtension, second use knowledge into FormsExtension how Latte works and how it register macros.

from forms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.