fredbob Posted April 15, 2017 Share Posted April 15, 2017 Hi, I am trying to create a frontend form that allows the user to create a page with a specific template (and fill out the fields) I have started to use code from this post This is my current code <?php $p = $pages->get(1029); $template = $p->template->name; // this is the template where we will get the fields from // make a form $form = $modules->get('InputfieldForm'); $form->method = 'post'; $form->action = './'; $form->attr("id+name",'subscribe-form'); // add the page's fields to the form $fields = $p->fieldgroup; foreach($fields as $field) { $inputfield = $fields->{$field->name}->getInputfield($p); $form->append($inputfield); } // add a submit button to the form $submit = $modules->get('InputfieldSubmit'); $submit->name = 'save_service'; $submit->attr("value", "Go"); $form->append($submit); // process the form if it was submitted if($this->input->post->save_service) { // now we assume the form has been submitted. // tell the form to process input from the post vars. $form->processInput($this->input->post); // see if any errors occurred if( count( $form->getErrors() )) { // re-render the form, it will include the error messages echo $form->render(); } else { // successful form submission $np = new Page(); // create new page object $np->template = 'service'; // set template $np->parent = $pages->get($user); // set the parent $np->of(false); // turn off output formatting before setting values $np->save(); foreach($np->fields as $f) { $np->set($f->name, $form->get($f->name)->value); } $np->save(); //create the page echo "<p>Page saved.</p>"; } } else { echo $form->render(); } And I am getting this error, I can't figure out what it is. Error: Exception: Unknown Selector operator: '' -- was your selector value properly escaped? (in /home/dev/public_html/wire/core/Selectors.php line 396) #0 /home/dev/public_html/wire/core/Selectors.php(439): ProcessWire\Selectors->create('41', '', '') #1 /home/dev/public_html/wire/core/Selectors.php(159): ProcessWire\Selectors->extractString('41') #2 /home/dev/public_html/wire/core/Selectors.php(145): ProcessWire\Selectors->setSelectorString(Object(ProcessWire\User)) #3 /home/dev/public_html/wire/core/PagesLoader.php(217): ProcessWire\Selectors->init(Object(ProcessWire\User)) #4 /home/dev/public_html/wire/core/Pages.php(232): ProcessWire\PagesLoader->find(Object(ProcessWire\User), Array) #5 /home/dev/public_html/wire/core/Wire.php(383): ProcessWire\Pages->___find(Object(ProcessWire\User), Array) #6 /home/dev/public_html/wire/core/WireHooks.php(698): ProcessWire\Wire->_callMethod('___find', Array) #7 /home/dev/public_html/wire/core/Wire.php(439): ProcessWire\WireHooks->runHooks(Object(ProcessWire\Pages), 'find', Ar This error message was shown because: you are logged in as a Superuser. Error has been logged. 1 Link to comment Share on other sites More sharing options...
Zeka Posted April 15, 2017 Share Posted April 15, 2017 Hi @xfroggy I'm not sure about this at all. $np->parent = $pages->get($user); // set the parent You are trying to set user page as parent for new page. Users pages can't have children. 1 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