mirror of
https://github.com/typemill/typemill.git
synced 2025-10-21 09:37:50 +02:00
Changed test plugin
This commit is contained in:
29
plugins/customfields/customfields.php
Normal file
29
plugins/customfields/customfields.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Plugins\Customfields;
|
||||
|
||||
use Typemill\Plugin;
|
||||
|
||||
class Customfields extends Plugin
|
||||
{
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
'onTwigLoaded' => 'onTwigLoaded',
|
||||
'onMetaLoaded' => 'onMetaLoaded'
|
||||
);
|
||||
}
|
||||
|
||||
public function onTwigLoaded()
|
||||
{
|
||||
$this->addEditorJS('/customfields/js/customfields.js');
|
||||
}
|
||||
|
||||
public function onMetaLoaded($meta)
|
||||
{
|
||||
$meta = $meta->getData();
|
||||
|
||||
# do something with the fields:
|
||||
$myTabInformation = $meta['mytab'];
|
||||
}
|
||||
}
|
15
plugins/customfields/customfields.yaml
Normal file
15
plugins/customfields/customfields.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
name: Customfields Plugin
|
||||
version: 1.0.0
|
||||
description: Plugin to test customfields
|
||||
author: Sebastian Schürmanns
|
||||
homepage: http://trendschau.net
|
||||
licence: No licence
|
||||
|
||||
metatabs:
|
||||
adamhall:
|
||||
fields:
|
||||
myfield:
|
||||
type: customfields
|
||||
label: Simple Custom Field
|
||||
description: Please add some custom fields
|
||||
data: array
|
26
plugins/customfields/js/customfields.js
Normal file
26
plugins/customfields/js/customfields.js
Normal file
@@ -0,0 +1,26 @@
|
||||
Vue.component('tab-adamhall', {
|
||||
props: ['saved', 'errors', 'formdata', 'schema'],
|
||||
template: '<section><form>' +
|
||||
'<component v-for="(field, index) in schema.fields"' +
|
||||
':key="index"' +
|
||||
':is="selectComponent(field)"' +
|
||||
':errors="errors"' +
|
||||
':name="index"' +
|
||||
'v-model="formdata[index]"' +
|
||||
'v-bind="field">' +
|
||||
'</component>' +
|
||||
'<div v-if="saved" class="metaLarge"><div class="metaSuccess">Saved successfully</div></div>' +
|
||||
'<div v-if="errors" class="metaLarge"><div class="metaErrors">Please correct the errors above</div></div>' +
|
||||
'<div class="large"><input type="submit" @click.prevent="saveInput" value="save"></input></div>' +
|
||||
'</form></section>',
|
||||
methods: {
|
||||
selectComponent: function(field)
|
||||
{
|
||||
return 'component-'+field.type;
|
||||
},
|
||||
saveInput: function()
|
||||
{
|
||||
this.$emit('saveform');
|
||||
},
|
||||
}
|
||||
})
|
Reference in New Issue
Block a user