我已经使用了embedRelation()到拉另一种形式到sfGuard用户形式。 它工作正常,我只是想给其样式以适应当前的形式。
这拉形式:
$this->embedRelation('Profile');
但补充说,我想删除一些额外的HTML元素:
<div class="form_row">
Profile
<table>
<tbody><tr>
<th><label for="sf_guard_user_Profile_department_title">Department</label></th>
<td><input type="text" name="sf_guard_user[Profile][department_title]" value="Graphic Design" id="sf_guard_user_Profile_department_title"><input type="hidden" name="sf_guard_user[Profile][id]" value="2" id="sf_guard_user_Profile_id">
<input type="hidden" name="sf_guard_user[Profile][sf_guard_user_id]" value="10" id="sf_guard_user_Profile_sf_guard_user_id"></td>
</tr>
</tbody></table> <input type="hidden" name="sf_guard_user[id]" value="10" id="sf_guard_user_id"> </div>
如何删除“档案”? 我还想标签不被包裹在一个表头。 这可能使用embedRelation?
将更新的模式格式化:
sfWidgetFormSchemaFormatter工作,以除去从嵌入形式的表元素。 我仍然无法弄清楚如何摆脱“档案”的。 我已经添加了sfWidgetFormSchemaFormatter
sfWidgetFormSchemaFormatterAc2009.class.php
<?php
class sfWidgetFormSchemaFormatterAc2009 extends sfWidgetFormSchemaFormatter
{
protected
$rowFormat = "%error% \n %label% \n %field%
%help% %hidden_fields%\n",
$errorRowFormat = "<div>%errors%</div>",
$helpFormat = '<div class="form_help">%help%</div>',
$decoratorFormat = "%content%";
public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null)
{
$row = parent::formatRow(
$label,
$field,
$errors,
$help,
$hiddenFields
);
return strtr($row, array(
'%row_class%' => (count($errors) > 0) ? ' form_row_error' : '',
));
}
public function generateLabel($name, $attributes = array())
{
$labelName = $this->generateLabelName($name);
if (false === $labelName)
{
return '';
}
if (!isset($attributes['for']))
{
$attributes['for'] = $this->widgetSchema->generateId($this->widgetSchema->generateName($name));
}
// widget name are usually in lower case. Only embed form have the first character in upper case
var_dump($name);
if (preg_match('/^[A-Z]/', $name))
{
// do not display label
return ;
}
else
{
return $this->widgetSchema->renderContentTag('label', $labelName, $attributes);
}
}
}
HTML:
<div class="form_row">
Profile
<div>
<label for="sf_guard_user_Profile_department_title">Department</label>
<input class=" text size-300" type="text" name="sf_guard_user[Profile][department_title]" value="Graphic Design" id="sf_guard_user_Profile_department_title">
<input type="hidden" name="sf_guard_user[Profile][id]" value="2" id="sf_guard_user_Profile_id">
</div> <input type="hidden" name="sf_guard_user[id]" value="10" id="sf_guard_user_id"> </div>
更新2:
新功能generateLabel($名称,$属性=阵列())在表格的顶部产生这样的:
串(16) “department_title”
简介遗体。
解决
我能acomplish此使用JQuery
我已将此添加到editSuccess.php模板:
<script>
var $body = $('.content-box');
var html = $body.html();
var newHtml = html.replace('Profile', '');
$body.html(newHtml);
</script>