You can the value in your controller before rendering the view :
$this->data['Category']['parent_id'], using the input('Category/
parent_id) ..will then get the value you have set into the controller
On Jun 11, 6:50 pm, r557 <[EMAIL PROTECTED]> wrote:
> Really basic here solution here i'm having an issue with.
>
> CONTROLLER FUNCTION
>
> function admin_add() {
> if(empty($this->data)) {
> $this->render();
> } else {
> $this->cleanUpFields();
> if($this->Category->save($this->data)) {
> $this->Session->setFlash('The Category has
> been saved');
> $this->redirect('/admin/categories/index');
> } else {
> $this->Session->setFlash('Please correct
> errors below.');
> }
> }
> }
>
> VIEW
>
> <h2>New Category</h2>
> <form action="<?php echo $html->url('/admin/categories/add'); ?>"
> method="post">
> <?php echo $html->hidden('Category/id')?>
> <div class="optional">
> <?php echo $form->labelTag('Category/active', 'Active');?>
> <?php echo $html->input('Category/active', array('size' => '60'));?>
> <?php echo $html->tagErrorMsg('Category/active', 'Please enter the
> Active.');?>
> </div>
> <div class="required">
> <?php echo $form->labelTag('Category/name', 'Name');?>
> <?php echo $html->input('Category/name', array('size' => '60'));?>
> <?php echo $html->tagErrorMsg('Category/name', 'Please enter the
> Name.');?>
> </div>
> <div class="required">
> <?php echo $form->labelTag( 'Category/description', 'Description' );?
>
> <?php echo $html->textarea('Category/description', array('cols' =>
> '60', 'rows' => '10'));?>
> <?php echo $html->tagErrorMsg('Category/description', 'Please enter
> the Description.');?>
> </div>
> <div class="optional">
> <?php echo $form->labelTag('Category/img', 'Img');?>
> <?php echo $html->input('Category/img', array('size' => '60'));?>
> <?php echo $html->tagErrorMsg('Category/img', 'Please enter the
> Img.');?>
> </div>
> <div class="optional">
> <?php echo $form->labelTag('Category/parentid', 'Parentid');?>
> <?php echo $html->input('Category/parentid', array('size' => '60'));?
>
> <?php echo $html->tagErrorMsg('Category/parentid', 'Please enter the
> Parentid.');?>
> </div>
> <div class="optional">
> <?php echo $form->labelTag('Category/sort_order', 'Sort Order');?>
> <?php echo $html->input('Category/sort_order', array('size' =>
> '60'));?>
> <?php echo $html->tagErrorMsg('Category/sort_order', 'Please enter
> the Sort Order.');?>
> </div>
> <div class="submit">
> <?php echo $html->submit('Add');?>
> </div>
> </form>
> <ul class="actions">
> <li><?php echo $html->link('List Categories', '/admin/categories/
> index')?></li>
> </ul>
>
> I have my model set up in a way that allows parentid's (nested
> categories). I have the link set up when i click to add a
> subcategory, the id is being passed, but i'm not sure how to populate
> properly in the value area of Category/parentid. I tried using a
> 'value' => '. $data['category']['id']' but that did not work.
>
> how do i get that add function to pass that id to the view?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---