我使用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