Maybe this is normal, but the SimpleHTMLEditorField I'm using does not generate p tags. It surrounds the text by divs instead, which makes the text entered in this field look different from everywhere else that the normal tinymce wysiwyg field is used.
Anybody know a work around or a fix for this? Here is how I am defining and using the field in the template:
DataObject
class UsedEquip extends DataObject{
static $db = array (
'Name' => 'Varchar(255)',
'Description' => 'HTMLText',
'Material' => "Enum('Mild Steel,Stainless Steel','Mild Steel')",
'Tanks' => 'Text',
'MaterialHandling' => "Enum('Conveyor,Drum,Monorail','Conveyor')",
'URLSegment' => 'Varchar(255)'
);
static $has_one = array (
'UsedEquipPage' => 'UsedEquipPage',
'Photo' => 'Image'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Name','Name'),
new SimpleHTMLEditorField('Description'),
new DropdownField(
$name = "Material",
$title = "Made From",
$source = singleton('UsedEquip')->dbObject('Material')->enumValues()
),
new TextField('Tanks','No. of Tanks'),
new DropdownField(
$name = "MaterialHandling",
$title = "Material Handling",
$source = singleton('UsedEquip')->dbObject('MaterialHandling')->enumValues()
),
new SimpleImageField('Photo')
);
}
function Thumbnail() {
$Photo = $this->Photo();
if ( $Photo ) {
return $Photo->CMSThumbnail();
} else {
return null;
}
}
public function onBeforeWrite(){
if($this->Name){
$this->URLSegment = SiteTree::GenerateURLSegment($this->Name);
if($object = DataObject::get_one($this->ClassName, "URLSegment='" .$this->URLSegment
."' AND ID !=".$this->ID)){
$this->URLSegment = $this->URLSegment.'-'.$this->ID;
}
// else {
//$this->URLSegment = SiteTree::GenerateURLSegment($this->ClassName.'-'.$this->ID);
//}
parent::onBeforeWrite();
}
}
}
Template Snippet:
<% control IndividualEquip %>
<div id="UsedImage">
$Photo.setWidth(600)
</div>
<div id="Overview" class="typography">
<p>Overview:</p>
<ul>
<li>Name: $Name</li>
<li>Construction: $Material</li>
<li>Material Handling: $MaterialHandling</li>
<li>Number of Tanks: $Tanks</li>
</ul>
</div>
<div id="Description" class="typography">
<p>Description:</p>
$Description
</div>
<% end_control %>
Thanks!