Help With: 500 - An error has occurred. JHtml: :element not supported. File not found.
Greetings,
First, thank you for such a great app. I have followed the steps to create a new element step-by-step, but always run into the same problem of error 500. Below I have pasted my code. If you could please let me with this, so I can learn to create this simple element, I can take it from there. Thank you in advance for your help!
address.xml
<?xml version="1.0" encoding="utf-8"?>
<element type="address" group="MY_GROUP" orderable="true">
<name>Address</name>
<author>John Doe</author>
<creationDate>April 2010</creationDate>
<copyright>THIS CAN PROBABLY BE OMITTED</copyright>
<authorEmail>john @ doe.com</authorEmail>
<authorUrl>http://www.johndoe.com</authorUrl>
<version>1.0.0</version>
<description>HTML address fields</description>
<params>
<param name="city" type="text" default="" label="City" description="" />
<param name="zip" type="text" default="" label="Zip" description="" />
<param name="country" type="text" default="" label="Country" description="" />
</params>
<params group="render">
<param name="separated_by" type="zoolist" default="Space" label="Separated by" description="CHOOSE_SEPARATOR_REPEATED_ELEMENTS">
<option name="Space"><![CDATA[separator=[ ]]]></option>
<option name="Comma"><![CDATA[separator=[, ]]]></option>
<option name="Hyphen"><![CDATA[separator=[ - ]]]></option>
<option name="Pipe"><![CDATA[separator=[ | ]]]></option>
<option name="Break"><![CDATA[separator=[<br />]]]></option>
<option name="Span"><![CDATA[tag=[<span>%s</span>]]]></option>
<option name="Paragraph"><![CDATA[tag=[<p>%s</p>]]]></option>
<option name="Div"><![CDATA[tag=[<div>%s</div>]]]></option>
<option name="List Item"><![CDATA[tag=[<li>%s</li>]]]></option>
<option name="Unordered List"><![CDATA[tag=[<li>%s</li>] enclosing_tag=[<ul>%s</ul>]]]></option>
<option name="Ordered List"><![CDATA[tag=[<li>%s</li>] enclosing_tag=[<ol>%s</ol>]]]></option>
<option name="Warp Item"><![CDATA[tag=[<article class="item">%s</article>]]]></option>
</param>
</params>
</element>
address.php
<?php
/**
* @package com_zoo
* @author YOOtheme http://www.yootheme.com
* @copyright Copyright (C) YOOtheme GmbH
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
// register ElementRepeatable class
App::getInstance('zoo')->loader->register('ElementRepeatable', 'elements:repeatable/repeatable.php');
/*
Class: ElementAddress
The address element class
*/
class ElementAddress extends ElementRepeatable implements iRepeatSubmittable {
/*
Function: _getSearchData
Get repeatable elements search data.
Returns:
String - Search data
*/
protected function _getSearchData() {
return $this->get('value', $this->config->get('default'));
}
/*
Function: _edit
Renders the repeatable edit form field.
Returns:
String - html
*/
public function _edit() {
$html = array();
$html[] = $this->app->html->_('element.editrow', 'Street', $this->app->html->_('control.text', $this->getControlName('street'), $this->get('street'), 'size="60" maxlength="255"'));
$html[] = $this->app->html->_('element.editrow', 'ZIP', $this->app->html->_('control.text', $this->getControlName('zip'), $this->get('zip'), 'size="60" maxlength="255"'));
$html[] = $this->app->html->_('element.editrow', 'Country', $this->app->html->_('control.text', $this->getControlName('country'), $this->get('country'), 'size="60" maxlength="255"'));
return implode("\n", $html);
}
/*
Function: _renderSubmission
Renders the element in submission.
Parameters:
$params - AppData submission parameters
Returns:
String - html
*/
public function render($params = array()) {
return $this->get('street') . ', ' . $this->get('zip') . ', ' .$this->get('country');
}
public function _renderSubmission($params = array()) {
return $this->_edit();
}
/*
Function: hasValue
Checks if the element's value is set.
Parameters:
$params - render parameter
Returns:
Boolean - true, on success
*/
public function hasValue($params = array()) {
$street = $this->get('street');
$zip = $this->get('zip');
$country = $this->get('country');
return !empty($street) ||!empty($zip) ||!empty($country);
}
}
Edited
