Statistics
572
1
0
1.2y
Badges
Tags
forms
Dependencies

Form factories for nette forms

Build Status

Installation

Neon

extensions:
    form: WebChemistry\Forms\DI\FormsExtension
    
form:
    factories:
    	front: WebChemistry\Forms\Factory\DefaultFormFactory

Faster containers


class ExampleForm extends WebChemistry\Forms\Control {

    public function createMyForm() {
        $form = $this->createForm();
        
        $form->addText('text', 'Text');
        
        $form->addText('container.text', 'Text');
        $form->addText('container.textTwo', 'Text two');
        
        $form->addContainer('container')->addText('container.text', 'Text');
        $form->addText('container.container.textTwo', 'Text two');
        
        unset($form['container.text']);
        isset($form['container.text']); /
        
        return $form;
    }
}

Reusable forms with WebChemistry\Forms\Control

Control:


class ExampleForm extends WebChemistry\Forms\Control {

    public function createMyForm() {
        $form = $this->createForm(); // Returns form by module from Application or default, if module not set

        $form->addText('text', 'Text');

        return $form;
    }

}

Presenter:

class FooPresenter extends Nette\Application\UI\Presenter {

    /** @var ExampleForm */
    private $exampleForm;

    public function __construct(ExampleForm $exampleForm) {
        $this->exampleForm = $exampleForm;
    }

    public function createComponentForm() {
        return $this->exampleForm->createMyForm();
    }

}

Custom factories

config:

form:
	factories:
		front: FrontFactory # for FrontModule
		admin: AdminFactory # for AdminModule

Is this addon outdated? Did you find an issue? Please report it.

Componette Componette admin@componette.com