http://www.nabble.com/How-to-make-a-good-use-of-Elements-and-DRY-principe---tf4279200.html#a12213971
Ski-3 wrote:
>
>
>> you can send a variable to the element:
>> renderElement('my_element', array('data' => $data));
>
> Hi,
>
> Thanks, I have been trying that, but the idea was to re-use the
> views I have already without having to change them.
>
> I "changed" the "standard" edit form over to an element by moving
> the file into the appropriate folder, but it does not render the model
> values in the form fields automatically, e.g. in my Food Menus edit
> view, I have a list of dishes that I want to have an edit form for -
> so I loop through them calling render element like so...
>
> <?php
> foreach ($foodMenu['MenuDish'] as $menuDish) {
> echo $this->renderElement('menu_dishes/admin_edit', array('data' =>
> array('MenuDish' => $menuDish)));
> } ?>
>
> my simplified element is the same as a standard edit form for the
> MenuDish and is as follows:
>
> <?php
> $this->data = $data;
> //print_r($this->data);
> ?>
>
> <form action="<?php echo $html->url('/admin/menu_dishes/edit/'.$html-
>>tagValue('MenuDish/id')); ?>" method="post" enctype="multipart/form-
> data">
> <div class="required">
> <?php echo $form->labelTag('MenuDish/title', 'Title');?>
> <?php echo $html->input('MenuDish/title', array('size' => '10'));?>
> <?php echo $html->tagErrorMsg('MenuDish/title', 'Please enter the
> Title.');?>
> </div>
> <div class="submit">
> <?php echo $html->submit('Save');?>
> </div>
> </form>
>
> This does not render the values of the MenuDish in the input in the
> same way as it would in a standard view. That's what I want to happen
> with my "nested" views.
>
> Thanks
>
> Glen
>
>
> >
>
>
--
View this message in context:
http://www.nabble.com/renderElement-vs-nesting-views-tf4013381.html#a12360108
Sent from the CakePHP mailing list archive at Nabble.com.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---