ariestikto ariestikto - 3 months ago 15
PHP Question

How to fill select options from custom database in .yaml files using typo3-neos?

i am currently using typo3-neos for my project and i have this problem.
i try to make my custom node like this in .yaml file

'TYPO3.Designs:SomeItem':
superTypes:
- 'TYPO3.Neos:Content'
ui:
group: 'structure'
label: 'Some Item'
icon: 'icon-columns'
inlineEditable: true
inspector:
groups:
document:
label: 'Item options'
position: 1
properties:
someitem:
type: string
defaultValue: 'item1'
ui:
label: 'Alignment'
reloadIfChanged: TRUE
inspector:
group: 'document'
editor: 'TYPO3.Neos/Inspector/Editors/SelectBoxEditor'
editorOptions:
values:
item1:
label: 'item1'
item2:
label: 'item2'
right:
label: 'item3'


in this part

editorOptions:
values:
item1:
label: 'item1'
item2:
label: 'item2'
right:
label: 'item3'


i want to take the data from database, so if in database have 10 items, it will appear 10 options at the editor.

how can i do that?
any help is appreciated, thanks

Answer

maybe the code is like this:

add this in your model

<?php
namespace Acme\YourPackage\DataSource;

use TYPO3\Neos\Service\DataSource\AbstractDataSource;
use TYPO3\TYPO3CR\Domain\Model\NodeInterface;

class TestDataSource extends AbstractDataSource {

        /**
         * @var string
         */
        static protected $identifier = 'acme-yourpackage-test';

        /**
         * Get data
         *
         * @param NodeInterface $node The node that is currently edited (optional)
         * @param array $arguments Additional arguments (key / value)
         * @return array JSON serializable data
         */
        public function getData(NodeInterface $node = NULL, array $arguments) {
                return isset($arguments['integers']) ? array(1, 2, 3) : array('a', 'b', 'c');
        }

}

and this is the yaml settings :

questions:
  ui:
    inspector:
      editor: 'Content/Inspector/Editors/SelectBoxEditor'
      editorOptions:
        dataSourceIdentifier: 'questions'
        # alternatively using a custom uri:
        # dataSourceUri: 'custom-route/end-point'

got this references from 'soee' http://docs.typo3.org/neos/TYPO3NeosDocumentation/IntegratorGuide/ContentStructure.html

Comments