From 3b9c38a1395885fe3ef97ede54428294efdf697f Mon Sep 17 00:00:00 2001 From: cwbit Date: Mon, 11 May 2015 12:38:25 -0400 Subject: [PATCH] added missing setup/usage steps There were a couple of steps missing from the usage/setup that, if not done, will render this behavior unusable by the app. I wasted a bit of time remembering to do each of these steps; figured it'd be nice to save the next person the trouble. --- README.md | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 560bfc9..7d5bd5c 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,24 @@ $this->addBehavior('Xety/Cake3Upload.Upload', [ ] ); ``` +Set your form to accept files +``` php + $this->Form->create($foo, ['type'=>'file']); + // .. or .. + $this->Form->create($foo, ['enctype' => 'multipart/form-data']); +``` +To create an input to upload a file, just use the this rule : **fieldName_file**. Example : +``` php +Form->input('avatar_file', ['type' => 'file']) ?> +``` +If specified in your Entity, add the suffixed field (e.g. `avatar_file`) to the `$_accessible` array: +``` php + protected $_accessible = [ + # .. + 'avatar_field' => true, + # .. + ]; +``` ### Identifiers * **:id** Id of the Entity (It can be the user Id if you are using this for the users table for example) @@ -43,11 +61,6 @@ $this->addBehavior('Xety/Cake3Upload.Upload', [ * **:y** Based on the current year. i.e : *2014* * **:m** Based on the current month. i.e : *09* -To create an input to upload a file, just use the this rule : **fieldName_file**. Example : -``` php -Form->input('avatar_file', ['type' => 'file']) ?> -``` - ## Configuration * ### suffix Default : `_file`