# Form to Resource

**URL:** <https://community.modx.com/t/form-to-resource/4551>\
**Category:** General\
**Created:** [October 29, 2021, 10:50am UTC](https://community.modx.com/t/form-to-resource/4551 "2021-10-29T10:50:05Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisandy](https://community.modx.com/user_avatar/community.modx.com/chrisandy/32/340_2.png) [@chrisandy](https://community.modx.com/u/chrisandy)\
**Post date:** [October 29, 2021, 10:50am UTC](https://community.modx.com/t/form-to-resource/4551/1 "2021-10-29T10:50:05Z")

</div>

Is there an accepted way for getting form submissions published directly as a resource?

I’m wanting to set up a very small neighbourhood site where people can send details of local tradespeople via a form which then creates an unpublished resource that I can then check and publish if acceptable.

---

<div class="post-metadata">

**Author:** ![bruno17](https://community.modx.com/user_avatar/community.modx.com/bruno17/32/71_2.png) [@bruno17](https://community.modx.com/u/bruno17)\
**Post date:** [October 29, 2021, 11:06am UTC](https://community.modx.com/t/form-to-resource/4551/2 "2021-10-29T11:06:46Z")

</div>

Maybe Newspublisher or Formit2Resource

---

<div class="post-metadata">

**Author:** ![chrisandy](https://community.modx.com/user_avatar/community.modx.com/chrisandy/32/340_2.png) [@chrisandy](https://community.modx.com/u/chrisandy)\
**Post date:** [October 29, 2021, 11:22am UTC](https://community.modx.com/t/form-to-resource/4551/3 "2021-10-29T11:22:40Z")

</div>

I think Formit2Resource looks the favourite simply because I’m familiar with Formit but do you think that’s the most up to date way of doing it?

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [October 29, 2021, 12:01pm UTC](https://community.modx.com/t/form-to-resource/4551/4 "2021-10-29T12:01:13Z")

</div>

Formit2Resource just uses `$modx->newObject('modResource');` which is the normal way of creating a new object in MODx.  
I’d use this snippet as a starting point and then customize it to your needs.

Alternatively you could call the “resource/create” processor `$modx->runProcessor('resource/create',$values);` if you have plugins that need to run on certain events (like ‘OnBeforeDocFormSave’ or ‘OnDocFormSave’) for this new resource.

---

<div class="post-metadata">

**Author:** ![lucy](https://community.modx.com/user_avatar/community.modx.com/lucy/32/43_2.png) [@lucy](https://community.modx.com/u/lucy)\
**Post date:** [October 29, 2021, 12:55pm UTC](https://community.modx.com/t/form-to-resource/4551/5 "2021-10-29T12:55:20Z")

</div>

I think a big question is if you want anonymous users to be able to view and submit the form.

If not, NewsPublisher does everything you need it to do and is actively updated and maintained by Bob Ray. Is a bit of a set up as you would imagine, highly configurable, the docs are great, and he is responsive if you get stuck.

> **[Bob's Guides | NewsPublisher Snippet](https://bobsguides.com/newspublisher-tutorial.html)**
>
> NewsPublisher is a front-end resource creation and editing tool. It allows users to create new documents and edit existing documents in the front end of your site.

---

<div class="post-metadata">

**Author:** ![andytough](https://community.modx.com/user_avatar/community.modx.com/andytough/32/54_2.png) [@andytough](https://community.modx.com/u/andytough)\
**Post date:** [October 29, 2021, 2:19pm UTC](https://community.modx.com/t/form-to-resource/4551/6 "2021-10-29T14:19:32Z")

</div>

If the form is publicly available you could reduce the security risk and the complexity by saving the Formit submissions, exporting them as .csv and using [ImportX](https://docs.modx.com/current/en/extras/importx/index) to create new resources from the rows in your (vetted) .csv file.

---

<div class="post-metadata">

**Author:** ![chrisandy](https://community.modx.com/user_avatar/community.modx.com/chrisandy/32/340_2.png) [@chrisandy](https://community.modx.com/u/chrisandy)\
**Post date:** [October 29, 2021, 2:23pm UTC](https://community.modx.com/t/form-to-resource/4551/7 "2021-10-29T14:23:41Z")

</div>

Thank you all. I’ve just got a basic version up and running using Formit with Formit2Resource. All seems to be working fine except the form redirect which I will sort out in due course.

The whole site will be password protected - just for use in the local community so I’m confident security will be fine.

---

<div class="post-metadata">

**Author:** ![chrisandy](https://community.modx.com/user_avatar/community.modx.com/chrisandy/32/340_2.png) [@chrisandy](https://community.modx.com/u/chrisandy)\
**Post date:** [October 29, 2021, 3:14pm UTC](https://community.modx.com/t/form-to-resource/4551/8 "2021-10-29T15:14:57Z")

</div>

Can’t work out why the redirect isn’t working. Saving the form and creating the resource is working, just not the redirect…

```auto
[[!FormIt?
    &hooks=`spam,email,FormItSaveForm,formit2resource,redirect`
    &preHooks=`resource2formit`
    &resource2formitfields=`pagetitle,alias,longtitle,description,introtext,content`
    &emailTpl=`candidate_email.chunk`
    &emailFrom=`[[$mainemail]]`
    &emailTo=`[[$mainemail]]`
    &redirectTo=`2`
    &submitVar=`Canreg`
    &emailUseFieldForSubject=`0`
    &emailSubject=`Directory Submission`
    &validate=`nospam:blank,parent:required,firstname:required,house:required,street:required,pagetitle:required,longtitle:required,description:required,content:required,
    email:email:required`]]

```

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [October 29, 2021, 3:17pm UTC](https://community.modx.com/t/form-to-resource/4551/9 "2021-10-29T15:17:29Z")

</div>

Does your custom hook snippet “formit2resource” return `true` at the end?

```auto
...
return true;

```

---

<div class="post-metadata">

**Author:** ![chrisandy](https://community.modx.com/user_avatar/community.modx.com/chrisandy/32/340_2.png) [@chrisandy](https://community.modx.com/u/chrisandy)\
**Post date:** [October 29, 2021, 3:21pm UTC](https://community.modx.com/t/form-to-resource/4551/10 "2021-10-29T15:21:59Z")

</div>

Yes it does but I’m wondering - is there a definite place to get those snippets from. I found them in previous forum posts.

---

<div class="post-metadata">

**Author:** ![chrisandy](https://community.modx.com/user_avatar/community.modx.com/chrisandy/32/340_2.png) [@chrisandy](https://community.modx.com/u/chrisandy)\
**Post date:** [October 29, 2021, 3:26pm UTC](https://community.modx.com/t/form-to-resource/4551/11 "2021-10-29T15:26:55Z")

</div>

Aha! the snippet resource2formit did not end like that but it now does and it works. Thank you so much. I would never have spotted that!
