Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using custom file/attachment field types #398

Open
Dodger77 opened this issue Sep 25, 2024 · 0 comments
Open

Using custom file/attachment field types #398

Dodger77 opened this issue Sep 25, 2024 · 0 comments

Comments

@Dodger77
Copy link

Q A
Bug? no
New Feature? yes
Bundle Version 2.5.4
Sulu Version 2.5.20
Browser Version n/a

Actual Behavior

There is the field type AttachmentFieldType, that is the only way to use file input elements in the SuluFormBundle because of the processing of uploaded files is tied to the field type name "attachment" (see

public const TYPE_ATTACHMENT = 'attachment';
).

AttachmentFieldType has the possiblity to restrict uploads to image, video and audio file types, but no other file type restrictions.

Expected Behavior

  • Possibility of adding custom upload/attachment field types (e.g. for different behavior/processing of uploaded files in form events)
  • Extending of the AttachmentFieldType by custom settings (e.g. other file type restrictions)

Steps to Reproduce

Is an current try to extend the AttachmentFieldType for using custom file type restriction, e.g.:

<properties xmlns="http://schemas.sulu.io/template/template"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:xi="http://www.w3.org/2001/XInclude"
            xsi:schemaLocation="http://schemas.sulu.io/template/template http://schemas.sulu.io/template/properties-1.0.xsd">
    <xi:include href="../../vendor/sulu/form-bundle/Resources/config/form-fields/default_field.xml"  xpointer="xmlns(sulu=http://schemas.sulu.io/template/template)
                      xpointer(//sulu:property)"/>
    <property name="options/type" type="select" colspan="6">
        <meta>
            <title>sulu_form.attachment_restrict</title>
            <info_text>sulu_form.attachment_restrict.hint</info_text>
        </meta>
        <params>
            <param name="values" type="collection">
                <param name="image">
                    <meta>
                        <title>sulu_form.attachment.image</title>
                    </meta>
                </param>
                <param name="audio">
                    <meta>
                        <title>sulu_form.attachment.audio</title>
                    </meta>
                </param>
                <param name="video">
                    <meta>
                        <title>sulu_form.attachment.video</title>
                    </meta>
                </param>
                <param name="document">
                    <meta>
                        <title>form_dynamic.attachment.document</title>
                    </meta>
                </param>
            </param>
        </params>
    </property>
    <property name="options/max" type="number" colspan="6">
        <meta>
            <title>sulu_form.attachment_max</title>
        </meta>
    </property>
</properties>

I saw the only way in using service decoration or compiler pass.

Possible Solutions

Like in my other issue (#397) a possible solution could be the use of the FormFieldTypeConfiguration group, because it seems to be not used anywhere at the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant