Initial commit of Config Controller and View.
* Allows basic updating of config options * No validation yet * All options are rendered as text boxes. Some need to be dropdown, etc.
This commit is contained in:
parent
869b84732d
commit
f35e7cbe73
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
class ConfigController extends AppController {
|
||||
|
||||
public function index() {
|
||||
$configs['fields'] = array('Name', 'Id', 'Value', 'Prompt', 'Type');
|
||||
$configs['order'] = array('Config.Category ASC');
|
||||
$this->set('configs', $this->Config->find('all', $configs));
|
||||
|
||||
if (!empty($this->request->data)) {
|
||||
$data = array();
|
||||
foreach ($this->request->data['Config'] as $key => $value) {
|
||||
foreach ($value as $fieldName => $fieldValue) {
|
||||
$arr = array('Config' => array('Name' => $fieldName, 'Value' => $fieldValue));
|
||||
array_push($data, $arr);
|
||||
}
|
||||
}
|
||||
|
||||
if($this->Config->saveMany($data)) {
|
||||
$this->Session->setFlash('Your config has been updated.');
|
||||
} else {
|
||||
$this->Session->setFlash('Your config has not been updated.');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,20 @@
|
|||
<h2>Configs</h2>
|
||||
<?php
|
||||
echo $this->Form->create('Config', array(
|
||||
'url' => '/config',
|
||||
'novalidate' => true
|
||||
));
|
||||
foreach ($configs as $config):
|
||||
$id = $config['Config']['Id'];
|
||||
$inputname = 'Config.' . $id . '.' . $config['Config']['Name'];
|
||||
echo $this->Form->input($inputname, array(
|
||||
'default' => $config['Config']['Value'],
|
||||
'label' => $config['Config']['Name'],
|
||||
'after' => $config['Config']['Prompt'],
|
||||
));
|
||||
endforeach;
|
||||
unset($config);
|
||||
echo $this->Form->end('Save Config');
|
||||
|
||||
?>
|
||||
</table>
|
Loading…
Reference in New Issue