Manaus Posted September 13, 2013 Share Posted September 13, 2013 Hello, I'm trying to hack some code for the FormTemplateProcessor module. I have this page structure: posts post 01 post 02 post 03 post 04 new post I'd like to add the new post as a sibling of 'new' but I get the page always as its child. This is the code I'm using: $form = $modules->get('FormTemplateProcessor'); $form->template = $templates->get('contact-form'); // required $form->requiredFields = array('title', 'body'); $form->email = 'my@email.com'; // optional, sends form as email $form->parent = $page; // optional, saves form as page echo $form->render(); // draw form or process submitted form Thanks for any suggestion! Link to comment Share on other sites More sharing options...
adrian Posted September 13, 2013 Share Posted September 13, 2013 I think you can probably replace: $form->parent = $page; with: $form->parent = $page->parent; 1 Link to comment Share on other sites More sharing options...
diogo Posted September 13, 2013 Share Posted September 13, 2013 I'm not sure what you are doing, but maybe it will work if you change $form->parent = $page; to $form->parent = $page->parent; edit: adrian was faster 1 Link to comment Share on other sites More sharing options...
Manaus Posted September 13, 2013 Author Share Posted September 13, 2013 It works very well!! I see the new pages are unpublished by default, is this tweakable?.. Thanks! Link to comment Share on other sites More sharing options...
adrian Posted September 13, 2013 Share Posted September 13, 2013 $form->addStatus(Page::statusUnpublished); Link to comment Share on other sites More sharing options...
Manaus Posted September 13, 2013 Author Share Posted September 13, 2013 Thanks adrian, I'm seeing this though: "Error: Exception: Method FormTemplateProcessor::addStatus does not exist or is not callable in this context" Link to comment Share on other sites More sharing options...
diogo Posted September 13, 2013 Share Posted September 13, 2013 Wouldn't it be $form->removeStatus(Page::statusUnpublished); instead? Link to comment Share on other sites More sharing options...
Manaus Posted September 13, 2013 Author Share Posted September 13, 2013 Looks like removeStatus does not exist either.. Link to comment Share on other sites More sharing options...
adrian Posted September 13, 2013 Share Posted September 13, 2013 diogo - thanks for spotting that - I misread what he wanted and forgot that unpublished is the default. As for the error - not really sure why that isn't working. Not really advisable, but you could hack the module code: https://github.com/ryancramerdesign/FormTemplateProcessor/blob/master/FormTemplateProcessor.module#L202 Comment out that highlighted line. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now