<![CDATA[ How to create Resources from the front end FormIt 4.0? - My Forums]]> https://forums.modx.com/thread/?thread=104286 <![CDATA[How to create Resources from the front end FormIt 4.0?]]> https://forums.modx.com/thread/104286/how-to-create-resources-from-the-front-end-formit-4-0#dis-post-560905 Snippets from here https://forums.modx.com/thread/31314/how-to-create-resources-documents-from-the-front-end-with-a-form
not working.

Anyone can help, please?]]>
antonfix Aug 18, 2018, 11:12 AM https://forums.modx.com/thread/104286/how-to-create-resources-from-the-front-end-formit-4-0#dis-post-560905
<![CDATA[Re: How to create Resources from the front end FormIt 4.0?]]> https://forums.modx.com/thread/104286/how-to-create-resources-from-the-front-end-formit-4-0#dis-post-560917
<?php

// Accessing the FormIt field (in example "name") in the hook

$name = $hook->getValue('name');

// Create resource with runProcessor

$prop = array(
	'pagetitle' => $name,
	'parent' => 1,
	'template' => 1,
	'isfolder' => 0,
	'deleted' => 0,
	'published' => 1
);
$response = $modx->runProcessor('resource/create', $prop);

if ($response->isError()) {
	return $modx->error->failure($response->getMessage());
}

return;
]]>
argonaut2k Aug 19, 2018, 08:13 AM https://forums.modx.com/thread/104286/how-to-create-resources-from-the-front-end-formit-4-0#dis-post-560917
<![CDATA[Re: How to create Resources from the front end FormIt 4.0?]]> https://forums.modx.com/thread/104286/how-to-create-resources-from-the-front-end-formit-4-0#dis-post-560911
1. Security -- NP does some serious sanitizing of all user input before writing anything to the DB

2. NP calls the Resource/Create processor, so any plugins will fire (e.g. defaultResourceGroup)

3. Easier to configure and change which fields show up in the form

4. Easier integration of TVs

5. Built-in Editing solution with EditThisButton.]]>
BobRay Aug 18, 2018, 09:40 PM https://forums.modx.com/thread/104286/how-to-create-resources-from-the-front-end-formit-4-0#dis-post-560911
<![CDATA[Re: How to create Resources from the front end FormIt 4.0?]]> https://forums.modx.com/thread/104286/how-to-create-resources-from-the-front-end-formit-4-0#dis-post-560907
<?php

// Create a new resource
$newResource = $modx->newObject('modDocument');

// Set resources properties
$newResource->set('pagetitle', 'New Resource');
$newResource->set('published', '1');
$newResource->set('template', '1');

$newResource->save();

return true;

]]>
lkfranklin Aug 18, 2018, 12:59 PM https://forums.modx.com/thread/104286/how-to-create-resources-from-the-front-end-formit-4-0#dis-post-560907