<?php
class InputfieldTapuEditor extends Inputfield {
public static function getModuleInfo() {
return array(
'title' => 'Inputfield Tapu Editor',
'summary' => 'Lomake-editori ilmoittautumislomakkeiden luontiin ja muokkaamiseen.',
'version' => 001,
'permanent' => true
);
}
protected $event_id = 0;
protected $current_form;
public function ready() {
}
public function ___render() {
$this->event_id = $this->input->get('id');
$form = new TapuFormsRender($this->input->get('id'));
$this->current_form = $form->returnFormArray();
/* Why are these required??
$this->config->scripts->add($this->config->urls->siteModules . "InputfieldTapuEditor/InputfieldTapuEditor.js");
$this->config->styles->add($this->config->urls->siteModules . "InputfieldTapuEditor/InputfieldTapuEditor.css");
*/
$out = "<div class='header'>Lataa mallipohja | Aloita uusi lomake | Tallenna pohja malliksi</div>";
$out .= "<ul id='valinnat'>";
foreach($this->current_form as $field) {
if (strlen($field['custom_id']) > 0) $id = $field['custom_id'];
else $id = $field['id'];
$attrs = array(
'selected' => 'selected'
);
$select->addOption($id, $field['nimi'], $attrs);
$out .= "<li class='tyyppi-". $field['tyyppi'] ."' data-id='$id'><a href=''><span class='ui-icon ui-icon-gear'></span>" . $field['nimi'] . "</a></li>";
}
$out .= "</ul>";
$out .= "<br><br><br><pre>";
$out .= print_r($this->current_form, true);
$out .= print_r($this->saatavillaKiinteat, true);
$out .= print_r($this->kaytetytKiinteat, true);
$out .= "Tää on editori</pre>";
return $out;
}
}
For some reason it doesn't load automatically the .css and .js files, called InputfieldTapuEditor.css|js
It might be because of the way that is initialized, it get's put into page editor through autoload module:
<?php
class TapuEventForm extends WireData implements Module {
public static function getModuleInfo() {
return array(
'title' => 'Tapu Event Form',
'summary' => 'Lisää tapahtumasivun muokkausnäkymään "ilmoittautumislomake" välilehden',
'version' => 001,
'permanent' => false,
'autoload' => true,
'singular' => true
);
}
public function init() {
}
public function ready() {
$page = wire('page');
if ($page->template->name != "admin") return;
$id = $this->input->get->id;
$page = wire('pages')->get($id);
if ($page->id) {
if ($page->template->name != "events-item") return;
} else {
return;
}
$this->addHookAfter('ProcessPageEdit::buildForm', $this, 'addFormTab');
}
public function addFormTab($event) {
$this->config->styles->add($this->config->urls->siteModules . "Tapu/Tapu.css");
$id = $this->input->get->id;
$wrapper = $event->return;
$formTab = new InputfieldWrapper();
$formTab->attr('id', $this->className() . 'View');
$formTab->attr('title', $this->_('Ilmoittautumislomake'));
$editor = new InputfieldTapuEditor();
$editor->label = $this->_("Ilmoittautumislomake");
$editor->attr('id', 'tapuEditor');
$formTab->append($editor);
$wrapper->append($formTab);
$event->return = $wrapper;
}
public function install() {
}
public function uninstall() {
}
}
Is the autoload module reason for not to load the .css and js?
Also: I am planning to use other Inputfield modules inside my InputfieldTapuEditor.module. Is that possible? They seem to render fine, but same problem there: no js or css loaded. Or rather: if I try to render AsmSelect field there, it gives me just a plain multiselect (I guess that is how it should work if js isn't available).












