getHelpText example

static::assertEquals([
            'en-GB' => 'To',
            'de-DE' => 'To DE',
        ]$firstInputField->getLabel());
        static::assertEquals([
            'en-GB' => 'Enter to...',
            'de-DE' => 'Enter to DE...',
        ]$firstInputField->getPlaceHolder());
        static::assertEquals([
            'en-GB' => 'Help text',
            'de-DE' => 'Help text DE',
        ]$firstInputField->getHelpText());

        static::assertTrue($firstInputField->getRequired());
        static::assertEquals('Shopware 6', $firstInputField->getDefaultValue());
    }
}
/** @var CustomFieldSet $customFieldSet */
        $customFieldSet = $manifest->getCustomFields()->getCustomFieldSets()[0];

        static::assertCount(1, $customFieldSet->getFields());

        $priceField = $customFieldSet->getFields()[0];
        static::assertInstanceOf(PriceField::class$priceField);
        static::assertEquals('test_price_field', $priceField->getName());
        static::assertEquals([
            'en-GB' => 'Test price field',
        ]$priceField->getLabel());
        static::assertEquals([]$priceField->getHelpText());
        static::assertEquals(1, $priceField->getPosition());
        static::assertFalse($priceField->getRequired());
    }

    public function testToEntityArray(): void
    {
        $priceField = $this->importCustomField(__DIR__ . '/_fixtures/price-field.xml');

        static::assertEquals('test_price_field', $priceField->getName());
        static::assertEquals('price', $priceField->getType());
        static::assertTrue($priceField->isActive());
        


    public function toArray(string $defaultLocale): array
    {
        $data = parent::toArray($defaultLocale);

        return array_merge($data[
            'name' => $this->getName(),
            'label' => $this->getLabel(),
            'placeHolder' => $this->getPlaceHolder(),
            'required' => $this->getRequired(),
            'helpText' => $this->getHelpText(),
            'defaultValue' => $this->getDefaultValue(),
            'options' => array_map(
                fn ($option) => \is_array($option) ? $option : json_decode($option, true),
                $this->getOptions() ?? []
            ),
            'type' => $this->getType(),
        ]);
    }

    public static function fromXml(\DOMElement $element): self
    {
        
$fields = [];

            foreach ($fieldSet->getFields() as $field) {
                $this->translateField($type$field);

                $fields[$field->getName()] = [
                    'fieldLabel' => $field->getLabel(),
                    'xtype' => $field->getType()::getExtjsField(),
                    'anchor' => '100%',
                    'translatable' => (bool) $field->isTranslatable(),
                    'supportText' => $field->getDescription(),
                    'helpText' => $field->getHelpText(),
                    'allowBlank' => !$field->isRequired(),
                ];

                $fields[$field->getName()] = array_merge($fields[$field->getName()]$field->getType()::getExtjsOptions($field)$field->getOptions());
            }

            $sets[] = array_merge([
                'title' => $fieldSet->getLabel(),
                'autoScroll' => true,
                'fields' => $fields,
                'anchor' => '100%',
            ],
/** @var CustomFieldSet $customFieldSet */
        $customFieldSet = $manifest->getCustomFields()->getCustomFieldSets()[0];

        static::assertCount(1, $customFieldSet->getFields());

        $singleSelectField = $customFieldSet->getFields()[0];
        static::assertInstanceOf(SingleSelectField::class$singleSelectField);
        static::assertEquals('test_single_select_field', $singleSelectField->getName());
        static::assertEquals([
            'en-GB' => 'Test single-select field',
        ]$singleSelectField->getLabel());
        static::assertEquals([]$singleSelectField->getHelpText());
        static::assertEquals(1, $singleSelectField->getPosition());
        static::assertEquals(['en-GB' => 'Choose an option...']$singleSelectField->getPlaceholder());
        static::assertFalse($singleSelectField->getRequired());
        static::assertEquals([
            'first' => [
                'en-GB' => 'First',
                'de-DE' => 'Erster',
            ],
            'second' => [
                'en-GB' => 'Second',
            ],
        ],
/** @var CustomFieldSet $customFieldSet */
        $customFieldSet = $manifest->getCustomFields()->getCustomFieldSets()[0];

        static::assertCount(1, $customFieldSet->getFields());

        $singleEntitySelectField = $customFieldSet->getFields()[0];
        static::assertInstanceOf(SingleEntitySelectField::class$singleEntitySelectField);
        static::assertEquals('test_single_entity_select_field', $singleEntitySelectField->getName());
        static::assertEquals([
            'en-GB' => 'Test single-entity-select field',
        ]$singleEntitySelectField->getLabel());
        static::assertEquals([]$singleEntitySelectField->getHelpText());
        static::assertEquals(1, $singleEntitySelectField->getPosition());
        static::assertEquals(['en-GB' => 'Choose an entity...']$singleEntitySelectField->getPlaceholder());
        static::assertFalse($singleEntitySelectField->getRequired());
        static::assertEquals('product', $singleEntitySelectField->getEntity());
    }

    public function testToEntityArray(): void
    {
        $singleEntitySelectField = $this->importCustomField(__DIR__ . '/_fixtures/single-entity-select-field.xml');

        static::assertEquals('test_single_entity_select_field', $singleEntitySelectField->getName());
        
/** @var CustomFieldSet $customFieldSet */
        $customFieldSet = $manifest->getCustomFields()->getCustomFieldSets()[0];

        static::assertCount(1, $customFieldSet->getFields());

        $dateTimeField = $customFieldSet->getFields()[0];
        static::assertInstanceOf(DateTimeField::class$dateTimeField);
        static::assertEquals('test_datetime_field', $dateTimeField->getName());
        static::assertEquals([
            'en-GB' => 'Test datetime field',
        ]$dateTimeField->getLabel());
        static::assertEquals([]$dateTimeField->getHelpText());
        static::assertEquals(1, $dateTimeField->getPosition());
        static::assertFalse($dateTimeField->getRequired());
    }

    public function testToEntityArray(): void
    {
        $dateTimeField = $this->importCustomField(__DIR__ . '/_fixtures/date-time-field.xml');

        static::assertEquals('test_datetime_field', $dateTimeField->getName());
        static::assertEquals('datetime', $dateTimeField->getType());
        static::assertTrue($dateTimeField->isActive());
        
/** @var CustomFieldSet $customFieldSet */
        $customFieldSet = $manifest->getCustomFields()->getCustomFieldSets()[0];

        static::assertCount(1, $customFieldSet->getFields());

        $boolField = $customFieldSet->getFields()[0];
        static::assertInstanceOf(BoolField::class$boolField);
        static::assertEquals('test_bool_field', $boolField->getName());
        static::assertEquals([
            'en-GB' => 'Test bool field',
        ]$boolField->getLabel());
        static::assertEquals([]$boolField->getHelpText());
        static::assertEquals(1, $boolField->getPosition());
        static::assertFalse($boolField->getRequired());
    }

    public function testToEntityArray(): void
    {
        $boolField = $this->importCustomField(__DIR__ . '/_fixtures/bool-field.xml');

        static::assertEquals('test_bool_field', $boolField->getName());
        static::assertEquals('bool', $boolField->getType());
        static::assertTrue($boolField->isActive());
        
/** @var CustomFieldSet $customFieldSet */
        $customFieldSet = $manifest->getCustomFields()->getCustomFieldSets()[0];

        static::assertCount(1, $customFieldSet->getFields());

        $multiSelectField = $customFieldSet->getFields()[0];
        static::assertInstanceOf(MultiSelectField::class$multiSelectField);
        static::assertEquals('test_multi_select_field', $multiSelectField->getName());
        static::assertEquals([
            'en-GB' => 'Test multi-select field',
        ]$multiSelectField->getLabel());
        static::assertEquals([]$multiSelectField->getHelpText());
        static::assertEquals(1, $multiSelectField->getPosition());
        static::assertEquals(['en-GB' => 'Choose your options...']$multiSelectField->getPlaceholder());
        static::assertFalse($multiSelectField->getRequired());
        static::assertEquals([
            'first' => [
                'en-GB' => 'First',
                'de-DE' => 'Erster',
            ],
            'second' => [
                'en-GB' => 'Second',
            ],
        ],
$customFieldSet = $manifest->getCustomFields()->getCustomFieldSets()[0];

        static::assertCount(1, $customFieldSet->getFields());

        $intField = $customFieldSet->getFields()[0];
        static::assertInstanceOf(IntField::class$intField);
        static::assertEquals('test_int_field', $intField->getName());
        static::assertEquals([
            'en-GB' => 'Test int field',
            'de-DE' => 'Test Ganzzahlenfeld',
        ]$intField->getLabel());
        static::assertEquals(['en-GB' => 'This is an int field.']$intField->getHelpText());
        static::assertEquals(1, $intField->getPosition());
        static::assertEquals(2, $intField->getSteps());
        static::assertEquals(0, $intField->getMin());
        static::assertEquals(1, $intField->getMax());
        static::assertEquals(['en-GB' => 'Enter an int...']$intField->getPlaceholder());
        static::assertTrue($intField->getRequired());
    }

    public function testToEntityArray(): void
    {
        $intField = $this->importCustomField(__DIR__ . '/_fixtures/int-field.xml');

        
static::assertCount(1, $customFieldSet->getFields());

        $field = $customFieldSet->getFields()[0];
        static::assertEquals('bool_field', $field->getName());
        static::assertEquals([
            'en-GB' => 'Test bool field',
            'de-DE' => 'Test bool field',
        ]$field->getLabel());
        static::assertEquals([
            'en-GB' => 'Help text',
            'de-DE' => 'Help text',
        ]$field->getHelpText());
    }
}
/** @var CustomFieldSet $customFieldSet */
        $customFieldSet = $manifest->getCustomFields()->getCustomFieldSets()[0];

        static::assertCount(1, $customFieldSet->getFields());

        $mediaSelectionField = $customFieldSet->getFields()[0];
        static::assertInstanceOf(MediaSelectionField::class$mediaSelectionField);
        static::assertEquals('test_media_selection_field', $mediaSelectionField->getName());
        static::assertEquals([
            'en-GB' => 'Test media-selection field',
        ]$mediaSelectionField->getLabel());
        static::assertEquals([]$mediaSelectionField->getHelpText());
        static::assertEquals(1, $mediaSelectionField->getPosition());
        static::assertFalse($mediaSelectionField->getRequired());
    }

    public function testToEntityArray(): void
    {
        $mediaSelectionField = $this->importCustomField(__DIR__ . '/_fixtures/media-selection-field.xml');

        static::assertEquals('test_media_selection_field', $mediaSelectionField->getName());
        static::assertEquals('text', $mediaSelectionField->getType());
        static::assertTrue($mediaSelectionField->isActive());
        
$customFieldSet = $manifest->getCustomFields()->getCustomFieldSets()[0];

        static::assertCount(1, $customFieldSet->getFields());

        $floatField = $customFieldSet->getFields()[0];
        static::assertInstanceOf(FloatField::class$floatField);
        static::assertEquals('test_float_field', $floatField->getName());
        static::assertEquals([
            'en-GB' => 'Test float field',
            'de-DE' => 'Test Kommazahlenfeld',
        ]$floatField->getLabel());
        static::assertEquals(['en-GB' => 'This is an float field.']$floatField->getHelpText());
        static::assertEquals(2, $floatField->getPosition());
        static::assertEquals(2.2, $floatField->getSteps());
        static::assertEquals(0.5, $floatField->getMin());
        static::assertEquals(1.6, $floatField->getMax());
        static::assertEquals(['en-GB' => 'Enter an float...']$floatField->getPlaceholder());
        static::assertFalse($floatField->getRequired());
    }

    public function testToEntityArray(): void
    {
        $floatField = $this->importCustomField(__DIR__ . '/_fixtures/float-field.xml');

        
/** @var CustomFieldSet $customFieldSet */
        $customFieldSet = $manifest->getCustomFields()->getCustomFieldSets()[0];

        static::assertCount(1, $customFieldSet->getFields());

        $textAreaField = $customFieldSet->getFields()[0];
        static::assertInstanceOf(TextAreaField::class$textAreaField);
        static::assertEquals('test_text_area_field', $textAreaField->getName());
        static::assertEquals([
            'en-GB' => 'Test text-area field',
        ]$textAreaField->getLabel());
        static::assertEquals([]$textAreaField->getHelpText());
        static::assertEquals(['en-GB' => 'Enter a text...']$textAreaField->getPlaceholder());
        static::assertEquals(1, $textAreaField->getPosition());
        static::assertFalse($textAreaField->getRequired());
    }

    public function testToEntityArray(): void
    {
        $textAreaField = $this->importCustomField(__DIR__ . '/_fixtures/text-area-field.xml');

        static::assertEquals('test_text_area_field', $textAreaField->getName());
        static::assertEquals('html', $textAreaField->getType());
        
/** @var CustomFieldSet $customFieldSet */
        $customFieldSet = $manifest->getCustomFields()->getCustomFieldSets()[0];

        static::assertCount(1, $customFieldSet->getFields());

        $multiEntitySelectField = $customFieldSet->getFields()[0];
        static::assertInstanceOf(SingleEntitySelectField::class$multiEntitySelectField);
        static::assertEquals('test_multi_entity_select_field', $multiEntitySelectField->getName());
        static::assertEquals([
            'en-GB' => 'Test multi-entity-select field',
        ]$multiEntitySelectField->getLabel());
        static::assertEquals([]$multiEntitySelectField->getHelpText());
        static::assertEquals(1, $multiEntitySelectField->getPosition());
        static::assertEquals(['en-GB' => 'Choose an entity...']$multiEntitySelectField->getPlaceholder());
        static::assertFalse($multiEntitySelectField->getRequired());
        static::assertEquals('product', $multiEntitySelectField->getEntity());
    }

    public function testToEntityArray(): void
    {
        $multiEntitySelectField = $this->importCustomField(__DIR__ . '/_fixtures/multi-entity-select-field.xml');

        static::assertEquals('test_multi_entity_select_field', $multiEntitySelectField->getName());
        
Home | Imprint | This part of the site doesn't use cookies.