My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php

/**
* entity form.
*
* @package worldmap
* @subpackage form
* @author Your name here
* @version SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class entityForm extends BaseentityForm
{
protected $mapProperties = array(
'address' => 'address',
'lat' => 'lat',
'lng' => 'lng'
);

public function configure()
{
unset($this['created_at']);
unset($this['updated_at']);
unset($this['entity_id']);
unset($this['type']);

$this->widgetSchema['map'] = new swWidgetFormGMapAddress();
$defaults = array();
$object = $this->getObject();
foreach ($this->mapProperties as $key => $property) {
unset($this[$key]);
$defaults[$property] = $object[$key];
}
$this->setDefault('map', $defaults);
$this->validatorSchema['map'] = new swValidatorGMapAddress();
}

protected function doUpdateObject($values)
{
if (isset($values['map'])) {
foreach ($this->mapProperties as $key => $property) {
if (isset($values['map'][$property])) {
$values[$key] = $values['map'][$property];
}
}
unset($values['map']);
}
$this->getObject()->fromArray($values);
}
}

Change log

r106 by lukas.smith on Dec 18, 2009   Diff
code beautifications, also made it
theoretically possible to have different
property names than those in the gmap
widget
Go to: 
Project members, sign in to write a code review

Older revisions

r102 by lukas.smith on Dec 18, 2009   Diff
tweaked the code a bit more
r101 by lukas.smith on Dec 18, 2009   Diff
cleaned up the code for the google map
handling
r99 by lukas.smith on Dec 18, 2009   Diff
made it possible to set the
address/lat/lng via google maps
All revisions of this file

File info

Size: 1244 bytes, 49 lines
Powered by Google Project Hosting