我使用cake bake命令創建了一個應用程序,一個表格使用文本作爲字段類型。爲什麼cakephp不能填充textarea?
所有的工作都很好,爲該字段生成了一個textarea,並按預期工作。 我保存了一些條目,查看它們編輯了幾個。
我意識到,使用編輯時,一個條目沒有填充textarea。它在視圖中正確顯示,但編輯數據時不在textarea中,並且保存會導致所有信息丟失。
這發生在一個普通的烘焙桌上。
這裏是我用它textarea的值:
上午克里斯托弗,
請你可以給我的密碼,我們的電子郵件帳戶在Citano因爲我們需要它來恢復我的主管電子郵件帳戶爲他的黑莓。
·您的緊急回覆在這件事上是必需的。
Jaques Kruger Citano Distributors。
是的,在那裏有一個奇怪的字符,我認爲從字的一個要點。
這是一個框架錯誤,稍後修復? 我在1.3.10和1.3.8上測試過。
任何幫助,將不勝感激。
編輯:
這裏是標準的出爐視圖 「edit.ctp」:
<div class="tickets form">
<?php echo $this->Form->create('Ticket', array('type'=>'file'));?>
<fieldset>
<legend><?php __('Edit Ticket'); ?></legend>
<?php
echo $this->Form->input('Ticket.id');
echo $this->Form->input('Ticket.name', array('label' => 'Ticket name'));
echo $this->Form->input('Ticket.details'); # Problem textarea not populating
echo $this->Form->input('Ticket.user_id', array('label' => 'Assigned to'));
echo $this->Form->input('Ticket.queue_id');
echo $this->Form->input('Ticket.client_id', array('options' => $clients,'default' => $defaultClient,'empty' => 'None'));
echo $this->Form->input('Ticket.status', array('options' => $ticketStatus));
echo $this->Form->input('Ticket.accepted', array('type' => 'checkbox'));
echo $this->Form->input('Ticket.linkedticketid', array('options' => $linkTickets,'empty' => 'None','style' => 'width:100%;','label' => 'Linked ticket'));
echo $this->Form->input('Ticket.due_date');
echo $this->Form->file('attachment');
echo $this->Form->input('email', array('label' => 'Additional email to mailing list'));
?>
</fieldset>
<?php echo $this->Form->end(__('Submit', true));?>
</div>
<div class="actions">
<h3><?php __('Actions'); ?></h3>
<ul>
<li><?php echo $this->Html->link(__('View Ticket', true), array('action' => 'view', $this->Form->value('Ticket.id'))); ?> </li>
<li><?php echo $this->Html->link(__('List Ticket', true), array('action' => 'index')); ?> </li>
</ul>
</div>
這裏是控制器:正如我之前所說
function edit($id = null) {
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid ticket', true));
$this->redirect(array('action' => 'index'));
}
if (!empty($this->data)) {
if ($this->Ticket->save($this->data)) {
$this->Session->setFlash(__('The Ticket has been saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The Ticket could not be saved. Please, try again.', true));
}
}
if (empty($this->data)) {
$this->data = $this->Ticket->read(null, $id);
}
}
中,數據已被添加,並且數據沒有任何問題,但編輯textarea時並不總是以現有數據填充,而其餘的o f這些字段始終填充現有數據。
調試數據在edit.ctp
Array
(
[Ticket] => Array
(
[id] => 281
[linkedticketid] =>
[user_id] => 1
[queue_id] => 4
[name] => password
[details] => Morning Christopher,
Please can you send me the password for our email accounts at Citano as we need it to reset my directors email account for his blackberry.
� Your urgent response is required in this matter.
Jaques Kruger
Citano Distributors.
[status] => 0
[accepted] => 0
[due_date] => 2011-11-12
[mailedtech] => 1
[uuid] => 34b12707-0b87-11e1-97b4-001e90d15e95
[created] =>
[modified] => 2011-11-10 12:48:51
)
[User] => Array
(
[id] => 1
[group_id] => 1
[name] => Christopher
[username] => Nightwolf
[password] => 8be1083780671a3b3541ff82r161d3d55a4e5d79
[email] => [email protected]
[created] => 2011-09-05 13:30:56
[modified] => 2011-09-05 13:31:34
)
[Queue] => Array
(
[id] => 4
[name] => Christopher
[rank] => 20
[created] => 2011-09-05 13:58:40
[modified] => 2011-09-05 13:58:40
)
[Task] => Array
(
)
[Ticketforclient] => Array
(
[0] => Array
(
[id] => 95
[ticket_id] => 281
[client_id] =>
[created] => 2011-11-10 12:34:45
[modified] => 2011-11-10 12:48:51
)
)
[Ticketnote] => Array
(
)
[Ticketsinqueue] => Array
(
[0] => Array
(
[id] => 67
[ticket_id] => 281
[queue_id] => 4
[created] =>
[modified] => 2011-11-10 12:48:50
)
)
[Activitylog] => Array
(
)
[Billinginfo] => Array
(
)
[Attachment] => Array
(
)
[Ticketmailinglist] => Array
(
[0] => Array
(
[id] => 11
[ticket_id] => 281
[emailaddress] => [email protected]
[originalsender] => 0
)
)
)
向我們展示代碼。如果你執行'debug($ this-> data)'你會看到那裏的文字嗎? – JJJ
@Juhana我已經添加了標準cakephp生成的代碼,你問。 – Nightwolf
因爲這些字段是從'$ this-> data'填充的。如果文本不存在,則不會將其插入到字段中。 – JJJ