我创建了表单,出现以下错误:
Call to a member function getTitleName() on a non-object in C:\wamp\www\public_html\apps\frontend\modules\planbook\templates\_form.php on line 25
这是我的代码:
<form method="post" enctype="multipart/form-data" action="<?php echo url_for((!isset($planbook) ? '@planbook_create' : '@planbook_update').(isset($planbook) ? '?id='.$planbook->getId() : '')) ?>">
<table>
<tfoot>
<tr>
<td colspan="2">
<a href="<?php echo url_for('planbook/index') ?>">Back to list</a>
<?php if (!$form->getObject()->isNew()): ?><?php endif; ?>
<input type="hidden" id="planbook_id" name="planbook[id]" value="<?php echo isset($planbook) ? $planbook->getId() : ' '?>" />
<input type="submit" value="Save" />
</td>
</tr>
</tfoot>
<tbody>
<tr>
<th>
<lable for="planbook_titlename"> Title</label>
</th>
<td>
<?php if(isset($editFormFields) && isset($editFormFields['titlename'])) :?>
<input type="text" id="planbook_titlename" name="planbook[titlename]" value="<?php echo isset($planbook) ? $planbook->getTitleName() : ''?>">
<?php else: ?>
<?php echo $planbook->getTitleName() ?>
<?php endif; ?>
</td>
</tr>
<tr>
<th>
<label for="planbook_place">Place</label>
</th>
<td>
<?php if(isset($editFormFields) && isset($editFormFields['place'])) :?>
<input type="text" id="planbook_place" name="planbook[place]" value="<?php echo isset($planbook) ? $planbook->getPlace() : ''?>">
<?php else: ?>
<?php echo $planbook->getPlace() ?>
<?php endif; ?>
</td>
</tr>
</tbody>
</table>
</form>