0

I have an administrative form that allows a user to set the save location of a file. I'd imagine that valid locations would be public://foo, private://foo, and /foo/bar/foo. What is the proper form field type to use in this situation, and would this option provide validation or would I have to write it myself?

My initial thought was to use a path field, but I'm not really sure how that would handle public/private paths. Would I need to convert those to routes somehow before passing the value through? I guess I'm also not sure if it's even possible to save a file outside of the public/private folders.

  • Do you require any kind of special features from that field? For example, autocomplete? – Ismail Cherri Sep 15 '18 at 6:09
  • @IsmailCherri I don't believe so. – Mrweiner Sep 15 '18 at 6:12
  • If the save locations are limited, why not use select? – Ismail Cherri Sep 15 '18 at 6:13
  • Options are not limited. It's meant to be a freetext field for the save destination, where foo/bar/etc in the examples above are just placeholders for wildcards. – Mrweiner Sep 15 '18 at 6:15
  • I don't think path or url are useful here. You can create your own field implementation where the user will type the path in a text field and will tick a checkbox for private or public. Then later on you can use the value in combination with file_create_url() to get the actual path – Ismail Cherri Sep 15 '18 at 6:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.