[NFR] Add widgets support
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
+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.
:+1:
+1
:+1:
+1
hi, could anyone propose the classes and methods that this functionality may require to be implemented, suggested syntax?
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.
Starting from 1.0.0, the forms builder is available in Phalcon, http://docs.phalconphp.com/en/latest/reference/forms.html
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 Why this currently cannot be created with the framework?
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?
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
Great! That's all what I need. Thanks!
Closing since no feedback was given
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 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.