Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UsersFormMapper extends Nette\Object
- {
- private static $map = array(
- 'name' => 'username',
- // ...
- );
- public function __construct(Nette\Application\UI\Form $form);
- public function save($entity)
- {
- foreach (self::$map as $f => $e) {
- if (isset($this->form[$f])) {
- $this->form[$f]->setDefaultValue($entity->{$e});
- }
- }
- }
- public function load()
- {
- foreach (self::$map as $f => $e) {
- if (isset($this->form[$f])) {
- $entity->{$e} = $this->form[$f];
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment