Created
July 31, 2016 21:45
-
-
Save soelen/046109e9fa1951a50560ab9dd16500d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<nav class="large-3 medium-4 columns" id="actions-sidebar"> | |
<ul class="side-nav"> | |
<li class="heading"><?= __('Actions') ?></li> | |
<li><?= $this->Html->link(__('List Images'), ['action' => 'index']) ?></li> | |
</ul> | |
</nav> | |
<div class="images form large-9 medium-8 columns content"> | |
<?= $this->Form->create($image, ['type' => 'file']) ?> | |
<fieldset> | |
<legend><?= __('Add Image') ?></legend> | |
<?php | |
echo $this->Form->input('name'); | |
echo $this->Form->input('dir'); | |
echo $this->Form->input('photo', ['type' => 'file']); | |
?> | |
</fieldset> | |
<?= $this->Form->button(__('Submit')) ?> | |
<?= $this->Form->end() ?> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Model\Table; | |
use Cake\ORM\Query; | |
use Cake\ORM\RulesChecker; | |
use Cake\ORM\Table; | |
use Cake\Validation\Validator; | |
/** | |
* Images Model | |
* | |
* @method \App\Model\Entity\Image get($primaryKey, $options = []) | |
* @method \App\Model\Entity\Image newEntity($data = null, array $options = []) | |
* @method \App\Model\Entity\Image[] newEntities(array $data, array $options = []) | |
* @method \App\Model\Entity\Image|bool save(\Cake\Datasource\EntityInterface $entity, $options = []) | |
* @method \App\Model\Entity\Image patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) | |
* @method \App\Model\Entity\Image[] patchEntities($entities, array $data, array $options = []) | |
* @method \App\Model\Entity\Image findOrCreate($search, callable $callback = null) | |
* | |
* @mixin \Cake\ORM\Behavior\TimestampBehavior | |
*/ | |
class ImagesTable extends Table | |
{ | |
/** | |
* Initialize method | |
* | |
* @param array $config The configuration for the Table. | |
* @return void | |
*/ | |
public function initialize(array $config) | |
{ | |
parent::initialize($config); | |
$this->table('images'); | |
$this->displayField('name'); | |
$this->primaryKey('id'); | |
$this->addBehavior('Timestamp'); | |
$this->addBehavior('Josegonzalez/Upload.Upload', [ | |
'photo', | |
]); | |
} | |
/** | |
* Default validation rules. | |
* | |
* @param \Cake\Validation\Validator $validator Validator instance. | |
* @return \Cake\Validation\Validator | |
*/ | |
public function validationDefault(Validator $validator) | |
{ | |
$validator | |
->integer('id') | |
->allowEmpty('id', 'create'); | |
$validator | |
->requirePresence('name', 'create') | |
->notEmpty('name'); | |
$validator | |
->allowEmpty('dir'); | |
$validator | |
->allowEmpty('photo'); | |
return $validator; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment