Passed
Pull Request — develop ( #58 )
by
unknown
32:22 queued 14:42
created

Component::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 50
Code Lines 35

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 35
dl 0
loc 50
rs 9.36
c 1
b 0
f 0
cc 1
nc 1
nop 0
ccs 0
cts 41
cp 0
crap 2
1
<?php
2
/**
3
 * @link http://www.newicon.net/neon
4
 * @copyright Copyright (c) 2017 Newicon Ltd
5
 * @license http://www.newicon.net/neon/license/
6
 * @author Steve O'Brien <[email protected]> 2019-11-03
7
 * @package neon
8
 */
9
10
namespace neon\cms\form;
11
12
13
class Component extends \neon\core\form\Form
14
{
15
	/**
16
	 * @inheritDoc
17
	 */
18
	public function init()
19
	{
20
		parent::init();
21
		$this->setName('component');
22
23
		$this->addFieldText('name', [
24
			'label'=>'Component name',
25
			'hint'=>'The name must be a unique string that identifies the component.  Note: A block name can only contain lowercase alphanumeric characters and dashes, and must begin with a letter, this is a html limitation.'
26
		])->setRequired();
27
28
		$this->addFieldText('title', [
29
			'label'=>'Component title',
30
			'hint'=>'Give the component a nice title - the component add menu will show this name.'
31
		])->setRequired();
32
33
		$this->addFieldTextArea('description', [
34
			'label'=>'Component Description',
35
			'hint'=>'A component description - this will be shown in the component inspector sidebar'
36
		])->setRequired();
37
38
		$this->addFieldText('icon', [
39
			'label'=>'Icon',
40
			'hint'=>'An icon property should be specified to make it easier to identify a component.  This can be a string class name or an svg element string'
41
		])->setRequired();
42
43
		$this->addFieldSelect('category', [
44
			'label'=>'Component Category',
45
			'hint'=>'Components are grouped into categories to help users browse and discover them.',
46
			'items' => ['common' => 'common', 'formatting' => 'formatting', 'layout' => 'layout']
47
		]);
48
49
		$this->addFieldText('keywords', [
50
			'label'=>'Keywords',
51
			'hint'=>'Enables users to search for components using different names for example text/paragraph.  Keywords are command separated',
52
		]);
53
54
		$this->addFieldText('parent', [
55
			'label'=>'Parent',
56
			'hint'=>'Components can be inserted into components that use a ComponentList. The ComponentList component handles a list of components.  Sometimes it is useful to only enable components to be added if their parent is a particular component.  For example only allowing column components to be added to a grid component. Ensures the component can only be added as a child of the parent specified.',
57
		]);
58
59
		$this->add([
60
			'name' => 'props_form',
61
			'class' => 'neon\core\form\fields\Builder',
62
			'label'=>'Props',
63
			'value' => '{"name": "props", "id": "props", "fields": [{"class": "text", "name":"text", "label":"Text box"}]}',
64
			'hint'=>'The form that creates the input parameters'
65
		]);
66
67
		$this->addFieldSubmit('Save');
68
	}
69
}