I have used the embedRelation() to pull another form into the sfGuard user form. It is working correctly, I am just trying to style it to fit into the current form.
This pulls the form in:
$this->embedRelation('Profile');
but it is adding some extra html elements that I would like to remove:
<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>
How can I remove "Profile"? I would also like the label to not be wrapped in a table header. Is this possible using embedRelation?
UPDATED Schema Formatter:
sfWidgetFormSchemaFormatter works to remove the table elements from the embedded form. I still can't figure out how to get rid of "Profile". I have added the 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>
UPDATE 2:
The new function generateLabel($name, $attributes = array()) is generating this at the top of the form:
string(16) "department_title"
Profile remains.
RESOLVED
I was able to acomplish this using JQuery
I added this to the editSuccess.php template:
<script>
var $body = $('.content-box');
var html = $body.html();
var newHtml = html.replace('Profile', '');
$body.html(newHtml);
</script>