euromark 11 years ago
parent
commit
d805190191
3 changed files with 21 additions and 11 deletions
  1. 18 2
      docs/Behavior/Jsonable.md
  2. 2 2
      docs/Upgrade.md
  3. 1 7
      src/Model/Behavior/SluggedBehavior.php

+ 18 - 2
docs/Behavior/Jsonable.md

@@ -24,6 +24,24 @@ Attach it to your models in `initialize()` like so:
 ```php
 $this->addBehavior('Tools.Jsonable', $config);
 ```
+
+Tip: If you have other behaviors that might modify the array data prior to saving, better use a higher priority:
+```php
+$this->addBehavior('Tools.Jsonable', array('priority' => 11, ...));
+```
+So that it is run last.
+
+## Examples
+
+The behavior supports different input/output formats:
+- "array" is the default input and output format
+- "list" is useful as some kind of pseudo enums or simple lists
+- "params" is useful for multiple key/value pairs
+- can be used to create dynamic forms (and tables)
+
+Also automatically cleans lists and works with custom separators/markup etc if you want it to.
+
+### Array
 In my first scenario where I used it, I had a geocoder behavior attached to the model which returned an array.
 I wanted to save all the returned values, though, for debugging purposes in a field "debug".
 By using the following snippet I was able to do exactly that with a single line of config.
@@ -42,8 +60,6 @@ and leave the source field untouched for any later usage.
 The same goes for the output: It will map the JSON content of "debug" back to the field "geocoder_result" as array, so
 I have both types available then.
 
-## Examples
-
 ### Params
 What if needed something more frontend suitable.
 I want to be able to use a textarea field where I can put all kinds of params

+ 2 - 2
docs/Upgrade.md

@@ -24,10 +24,10 @@
 
 ### SluggedBehavior
 - Model names are now table names, and plural.
-- Slugged option "slugField" is now "field", "multiSlug" has been removed for now as well as currencies.
+- Slug field name option "slugField" is now "field", "multiSlug" has been removed for now as well as currencies.
 
 ### PasswordableBehavior
-- You can/should now specify a "validator", defaluts to "default".
+- You can/should now specify a "validator", it defaults to "default".
 
 ### JsonableBehavior
 - No auto-detect anymore, fields need to be specified manually

+ 1 - 7
src/Model/Behavior/SluggedBehavior.php

@@ -1,11 +1,4 @@
 <?php
-/**
- * @copyright Copyright (c) 2008, Andy Dawson
- * @author Andy Dawson
- * @author Mark Scherer
- * @license http://www.opensource.org/licenses/mit-license.php The MIT License
- */
-
 namespace Tools\Model\Behavior;
 
 use Cake\Event\Event;
@@ -23,6 +16,7 @@ use Cake\Error\Exception;
  *
  * Usage: See docs
  *
+ * @author Andy Dawson
  * @author Mark Scherer
  * @license MIT
  */