I work with a similar thing right now.

The edit view:

<?php echo $form->create('Contentclass');?>
        <fieldset>
                <legend><?php __('Edit Contentclass');?></legend>
        <?php
                echo $form->input('id');
                echo $form->input('title');
                echo $form->input('attribute_identifier');
                echo $form->input('is_container');
                echo $form->input('contentclassgroup_id');
        ?>
        </fieldset>
        <?php if(!empty($this->data['ContentclassAttribute'])): ?>
        <fieldset>
                <legend><?php __('Attributes');?></legend>
                <?php $n = 0; foreach($this->data['ContentclassAttribute'] as
$att): ?>
                <fieldset class="attribute">
                        <legend><?php __('Attribute Type: ' . 
$att['attribute_type']);?></
legend>
                <?php
                        echo $form->input("ContentclassAttribute.{$n}.id", 
array('value'=>
$att['id']));
                        echo $form->input("ContentclassAttribute.{$n}.title",
array('value'=>$att['title']));
                        echo 
$form->input("ContentclassAttribute.{$n}.placement",
array('value'=>$att['placement']));
                        echo 
$form->input("ContentclassAttribute.{$n}.is_required",
array('value'=>$att['is_required']));
                        echo 
$form->input("ContentclassAttribute.{$n}.is_searchable",
array('value'=>$att['is_searchable']));
                        echo 
$form->hidden("ContentclassAttribute.{$n}.attribute_type",
array('value'=>$att['attribute_type']));
                        echo $html->link(__('Remove this attribute', true),
array('action'=>'removeAttribute', $form->value('Contentclass.id'),
$att['id']), null, sprintf(__('Are you sure you want to remove this
attribute with title %s?', true), $att['title']));
                        $n++;
                ?>
                </fieldset>
        <?php endforeach; ?>
        </fieldset>
        <?php endif; ?>
<?php echo $form->end('Save');?>
<?php echo $form->create(null, array('action' => 'addattribute'));?>
<fieldset class="attribute addattribute">
        <legend><?php __('Add attribute');?></legend>
        <div><?php echo $form->select("ContentclassAttribute.attribute_type",
$attribute_types, null, null, ""); ?></div>
        <?php echo $form->end('Add new attribute');?>
</fieldset>
</div>

And the controller:

function edit($id = null) {
                if (!$id && empty($this->data)) {
                        $this->Session->setFlash(__('Invalid Contentclass', 
true));
                        $this->redirect(array('action'=>'index'));
                }
                if (!empty($this->data)) {
                        if ($this->Contentclass->saveAll($this->data)) {
                                $this->Session->setFlash(__('The Contentclass 
has been saved',
true));
                        } else {
                                $this->Session->setFlash(__('The Contentclass 
could not be saved.
Please, try again.', true));
                        }
                }
                if (empty($this->data)) {
                        $this->data = $this->Contentclass->read(null, $id);
                }
                $contentclassgroups = $this->Contentclass->Contentclassgroup-
>find('list');
                $this->set('attribute_types', $this->Contentclass-
>ContentclassAttribute->getAttributeTypes());
                $this->set(compact('contentclassgroups'));
        }

Hope this helps!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to