cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[NFR] Add widgets support

Open nekulin opened this issue 13 years ago • 16 comments

Are there any plans to implement a forms builder? example symfony 1/4 and symfony 2. If it were possible frameworks symfony or Yii price would not have

nekulin avatar Dec 29 '12 18:12 nekulin

+1 It would be nice to create native widget support (mini mvc) It would be nice to create post on phalcon website which show side by side how widget work in yii vs phalcon, it could grab people from yii to use phalcon, it could help to convert yii widgets to phalcon widgets. We need widget system to snowball popularity in phalcon, it could help to create community near widget ecosystem.

doit76 avatar Jan 05 '13 12:01 doit76

:+1:

roman-kulish avatar May 10 '13 01:05 roman-kulish

+1

ghost avatar May 13 '13 05:05 ghost

:+1:

iforp avatar May 13 '13 08:05 iforp

+1

milchinskiy avatar May 14 '13 18:05 milchinskiy

hi, could anyone propose the classes and methods that this functionality may require to be implemented, suggested syntax?

ghost avatar May 14 '13 18:05 ghost

I think tedious look at the 2 branch symfony. The main thing is that this work is very fast and make default валидаторы. http://symfony.com/doc/current/book/forms.html To be honest I liked in 1 thread version 1.4. The main thing is that you can easily customize them. And description of the forms must be in the class of the form and not in the controller.

nekulin avatar May 14 '13 19:05 nekulin

Starting from 1.0.0, the forms builder is available in Phalcon, http://docs.phalconphp.com/en/latest/reference/forms.html

ghost avatar May 14 '13 19:05 ghost

Well, I saw Symfony's form builder and I think it's very overloaded. Actually, we can use something like widgets right now by (in the view), for example:

$widget = new MySomeCoolestWidget(array $initParams = array()); $widget->getContents();

But all I want to see in the phalcon is getting result content from the view, I mean something like that:

class MySomeCoolestWidget
{
  public function execute() 
  {
    // TODO: general business logic
  }

  public function getContents()
  {
    return $this->getViewContent($viewNameOrPath, array $data = array()); // that is exactly what I want to have in any of the components, like \Phalcon\DI::getDefault() - I can get it in any place of the project
  }
}

of course , it's just my point.

milchinskiy avatar May 14 '13 19:05 milchinskiy

@milchinskiy Why this currently cannot be created with the framework?

ghost avatar May 14 '13 21:05 ghost

Well, I'm not sure, but I have no idea how to get the rendered template content in the external class. Can you tell me documentation section where it was described?

milchinskiy avatar May 14 '13 21:05 milchinskiy

You can create a class MyWidgets:

class MyWidgets extends Phalcon\DI\Injectable
{
    public function getViewContent($path, $data=array())
    {
        $paths = explode('/', $path, 1);
        return $this->view->getRender($paths[0], $paths[1], $data);
    }
}

Then use it as base for widgets:

class MySomeCoolestWidget extends MyWidgets
{
  public function execute() 
  {
    // TODO: general business logic
  }

  public function getContents()
  {
     return $this->getViewContent('emailTemplates/my-view', array('some' => 1, 'var' => 2)); 
  }
}

http://docs.phalconphp.com/en/latest/reference/views.html#stand-alone-component

ghost avatar May 14 '13 21:05 ghost

Great! That's all what I need. Thanks!

milchinskiy avatar May 14 '13 21:05 milchinskiy

Closing since no feedback was given

ghost avatar Oct 02 '13 05:10 ghost

hi @phalcon

that was a great way, one point maybe i am still want to discuss , is possible form builder phalcon have method to give the output string (HTML TAG) after some set element and config from?

viyancs avatar Sep 01 '16 09:09 viyancs

@viyancs We only accept bug reports, new feature requests and pull requests in GitHub. For questions regarding the usage of the framework, support requests, and questions like this please visit the official forums.

sergeyklay avatar Sep 01 '16 10:09 sergeyklay