Manaus Posted September 13, 2013 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!
adrian Posted September 13, 2013 Posted September 13, 2013 I think you can probably replace: $form->parent = $page; with: $form->parent = $page->parent; 1
diogo Posted September 13, 2013 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
Manaus Posted September 13, 2013 Author Posted September 13, 2013 It works very well!! I see the new pages are unpublished by default, is this tweakable?.. Thanks!
adrian Posted September 13, 2013 Posted September 13, 2013 $form->addStatus(Page::statusUnpublished);
Manaus Posted September 13, 2013 Author 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"
diogo Posted September 13, 2013 Posted September 13, 2013 Wouldn't it be $form->removeStatus(Page::statusUnpublished); instead?
Manaus Posted September 13, 2013 Author Posted September 13, 2013 Looks like removeStatus does not exist either..
adrian Posted September 13, 2013 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.
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