Skip to content

Instantly share code, notes, and snippets.

@jippi
Created April 18, 2014 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jippi/11040168 to your computer and use it in GitHub Desktop.
Save jippi/11040168 to your computer and use it in GitHub Desktop.
diff --git i/src/ORM/Marshaller.php w/src/ORM/Marshaller.php
index da6b8c9..d5cacc7 100644
--- i/src/ORM/Marshaller.php
+++ w/src/ORM/Marshaller.php
@@ -245,15 +245,22 @@ class Marshaller {
}
$properties = [];
+ $schema = $this->_table->schema();
foreach ($data as $key => $value) {
$original = $entity->get($key);
if (isset($propertyMap[$key])) {
$assoc = $propertyMap[$key]['association'];
$nested = $propertyMap[$key]['nested'];
$value = $this->_mergeAssociation($original, $assoc, $value, $nested);
- } elseif ($original == $value) {
+ } elseif ($columnType = $schema->columnType($key)) {
+ $converter = Type::build($columnType);
+ $value = $converter->marshal($value);
+ }
+
+ if ($original == $value) {
continue;
}
+
$properties[$key] = $value;
}
diff --git i/src/ORM/Table.php w/src/ORM/Table.php
index 38ef084..4cea54b 100644
--- i/src/ORM/Table.php
+++ w/src/ORM/Table.php
@@ -1090,7 +1090,14 @@ class Table implements RepositoryInterface, EventListener {
]);
if ($entity->isNew() === false && !$entity->dirty()) {
- return $entity;
+ $associated = $options['associated'];
+ $options['associated'] = [];
+
+ if ($options['validate'] && !$this->validate($entity, $options)) {
+ return false;
+ }
+
+ return true;
}
if ($options['atomic']) {
diff --git i/src/View/Helper/FormHelper.php w/src/View/Helper/FormHelper.php
index f686f11..080377e 100755
--- i/src/View/Helper/FormHelper.php
+++ w/src/View/Helper/FormHelper.php
@@ -105,6 +105,7 @@ class FormHelper extends Helper {
'groupContainer' => '<div class="input {{type}}{{required}}">{{content}}</div>',
'groupContainerError' => '<div class="input {{type}}{{required}} error">{{content}}{{error}}</div>',
'submitContainer' => '<div class="submit">{{content}}</div>',
+ 'inputOnlyGroup' => '{{input}}'
]
];
@@ -844,8 +845,15 @@ class FormHelper extends Helper {
$input = $this->_getInput($fieldName, $options);
$label = $this->_getLabel($fieldName, compact('input', 'label') + $options);
- $groupTemplate = $options['type'] === 'checkbox' ? 'checkboxFormGroup' : 'formGroup';
- $result = $this->formatTemplate($groupTemplate, compact('input', 'label'));
+ if ($options['type'] === 'checkbox') {
+ $groupTemplate = 'checkboxFormGroup';
+ } elseif ($options['type'] === 'hidden') {
+ $groupTemplate = 'inputOnlyGroup';
+ } else {
+ $groupTemplate = 'formGroup';
+ }
+
+ $result = $this->formatTemplate($groupTemplate, compact('input', 'label', 'error'));
if ($options['type'] !== 'hidden') {
$result = $this->formatTemplate($template, [
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment