Tuesday, April 27, 2010

Re: Problem in using elements

Hi John
Thanks for your quick reply!
here is my edit method :

function edit($id = null) {
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid User', true));
$this->redirect(array('action'=>'login'));
}
if (!empty($this->data)) {
if ($this->User->save($this->data)) {
$this->Session->setFlash(__('The User has been saved', true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('The User could not be saved. Please, try
again.', true));
}
}
if (empty($this->data)) {
$this->data = $this->User->read(null, $id);
}
$coupons = $this->User->Coupon->find('list');
$this->set(compact('coupons'));
}

Actually it's working from edit view but not from edit element!!! I'm new in
cakephp!! is there anything special with elements? aren't they working just
like views?

Thanks
Sherry

John Andersen-6 wrote:
>
> In the controller action for the view in which you are using the edit
> element, make sure that you fill out the $this->data array with the
> data that the edit element need!
> As you are using the form helper in the edit element, then the form
> helper takes the data from $this->data.
> Enjoy,
> John
>
> On Apr 27, 10:23 pm, sherzo <shahrzad.azimi...@gmail.com> wrote:
>> Hi all!!!
>> I have a user edit page, which works perfectly. Somehow I need to make an
>> element of the the edit form and load it in another page as well. but
>> when I
>> load the edit element its an empty page!!! How can I load the date to the
>> form while its an element?
>> Any idea??
>> here is my edit.ctp
>>
>> <?php echo $form->create('User',  array('action' => 'edit','type' =>
>> 'post','class'=>'center', 'id' => 'kaydet', 'name' => 'kaydet' ));?>
>>  <div>Ad, Soyad <?php echo $html->image("firsat-bullet.gif",
>> array("align"
>> => "absmiddle", "alt" =>"" )); ?>
>>    <p><?php
>>  echo $form->input('id',array('type' => 'hidden'));
>>  echo $form->input('username', array('type' => 'hidden'));
>>  echo $form->text('first_name',array('class' => 'formInput'));
>>  echo $form->text('last_name',array('class' => 'formInput'));
>>  ?>
>>      Kartýnýzýn arkasýndaki son 3 rakam.</p>
>>  </div>
>>  <div>E-Posta<?php echo $html->image("firsat-bullet.gif", array("align"
>> =>
>> "absmiddle", "alt" =>"" )); ?>
>>
>>    <p>
>>    <?php echo $form->text('email',array('class' => 'formInput'));
>> ?>
>>    </p>
>>  </div>
>>  <div>Cep Telefonu<?php echo $html->image("firsat-bullet.gif",
>> array("align"
>> => "absmiddle", "alt" =>"" )); ?>
>>    <p>
>>     <?php echo $form->text('telephone',array('class' => 'formInput'));
>> ?>
>>    </p>
>>  </div>
>>  <p class="kaydet">
>> <?php echo $form->submit('degisikleri-kaydet-button.gif',
>> array('class'=>'submit'));?>
>>  </p>
>>  <br class="cb" />
>> <?php echo $form->end(); ?>
>> --
>> View this message in
>> context:http://old.nabble.com/Problem-in-using-elements-tp28380990p28380990.html
>> Sent from the CakePHP mailing list archive at Nabble.com.
>>
>> Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 cake-php@googlegroups.com
>> To unsubscribe from this group, send email to
>> cake-php+unsubscribe@googlegroups.com For more options, visit this group
>> athttp://groups.google.com/group/cake-php?hl=en
>
> 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 cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php?hl=en
>
>

--
View this message in context: http://old.nabble.com/Problem-in-using-elements-tp28380990p28381113.html
Sent from the CakePHP mailing list archive at Nabble.com.

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: