Im useing joomla 2.5, và tôi muốn tạo ra một loại lĩnh vực hình thức tùy chỉnh that stored in the same module.
Cách tạo loại trường biểu mẫu tùy chỉnh trong mô-đun?
Trong XML:
<fieldset name="basic" addfieldpath="/modules/mod_royalslider/fields"></fields>
<fieldset name="basic">
<field name="title" type="City" label="anythging" description="" />
</fieldset>
</fields>
Trong tập tin /modules/mod_royalslider/fields/city.php
<?php
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
jimport('joomla.form.formfield');
class JFormFieldCity extends JFormField {
protected $type = 'City';
// getLabel() left out
public function getInput() {
return '<select id="'.$this->id.'" name="'.$this->name.'">'.
'<option value="1" >New York</option>'.
'<option value="2" >Chicago</option>'.
'<option value="3" >San Francisco</option>'.
'</select>';
}
}
cho bây giờ nó chỉ cho tôi lỗi , khi nào tôi xóa <fieldset name="basic" addfieldpath="/modules/mod_royalslider/fields"></fields>
lỗi mới nhất e và trường disply như một trường văn bản.
Không hoạt động. Tuy nhiên, đó là một con đường ở cuối tôi chuyển tập tin php vào cùng một đường dẫn. Mọi cơ thể đều có tệp nguồn mở! – alnassre
@alnassre Tôi đã cập nhật mã này. – Toretto
Đã làm việc = D Hoooray – alnassre