Here is the thing:
The basic Idea is to have a list of devices,
every device belongs to a type (say server, switch, screen, mouse...).
depending on the type, different fields should be displayed in the views
(ip address for server, screen size for screen...).
Database (simplified):
Table devices
* id
* name
Table device_types
* id
* name
Table fields
* id
* name
Table field_values
* id
* field_id
* device_id
* value
Table devicetypes_fields
* id
* device_type_id
* field_id
it might be that this model is not perfect, just tell me...
what i tried (and its working for the view, but i dont know how to start for
the edit views) is this:
devices_controller.php:view()
[...]
// load FieldList
$this->loadModel('DevicetypesField');
$a = $this->DevicetypesField->find('all',
array(
'conditions' => array('DevicetypesField.device_type_id'
=> $this->viewVars['device']['DeviceType']['id'])
, 'fields' => array('DevicetypesField.field_id')
)
);
// Load Field Names
$this->loadModel('Field');
$this->set('fields',
$this->DevicetypesField->find('all',
array(
'conditions' => array(
'DevicetypesField.device_type_id' =>
$this->viewVars['device']['DeviceType']['id']
, 'Field.enabled' => 1
)
, 'fields' => array('Field.name')
)
)
);
[...]
view.tcp
[...]
<?php
for($fieldId = 0;$fieldId < count($fields);$fieldId++) {
$field = $fields[$fieldId];
echo '<dt';
if ($i % 2 == 0) echo $class . '>';
__($field['Field']['name']);
echo '</dt><dd';
if ($i++ % 2 == 0) echo $class . '>';
echo $device['FieldValue'][$fieldId]['value'] . ' ';
echo '</dd>';
}
?>
[...]
how do i implement this with cakephp, in the intended way?
any help is appreciated.
Dani
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en