Jump to content

Creating page: Body field & redirection to newly created page


ankh2054
 Share

Recommended Posts

Hi all,

One problem and one question:

  1. Problem: The below code does not update the body field attached to the template (discussions)
  2. Question: What type of redirect can I use to redirect session to newly created page after page save.

Code

// Process new page creation if($input->post->create_submit) {

//Sanatize variables taking in the form data
$title = $sanitizer->text($input->post->title);
$body =  $sanitizer->textarea($input->post->body);



$p = new Page(); // create new page object
$p->template = 'discussions'; // set template
$p->parent = wire('pages')->get('/discuss/'); // set the parent 
$p->title = $title; // set page title (not neccessary but recommended)
$P->body = $body; //Set the body 
$p->save(); 

}




?>



       <form class="form-horizontal" action="./" accept-charset="UTF-8" autocomplete="off" method="post">
       <div class="form-group">
       <label for="inputFullname3" class="col-sm-2 control-label">Title</label>
       <div class="col-sm-10">
       <input type="text" class="form-control" name="title" placeholder="Enter the Title" >
       </div>
       </div>
       <div class="form-group">
       <label for="inputEmail3" class="col-sm-2 control-label">Body</label>
       <div class="col-sm-10">
       <textarea name='body' rows='5' cols='45' id='body' placeholder="Your message"></textarea>
       </div>
       </div>
       
       <button class="btn btn-lg btn-primary" type="submit" name="create_submit" value="create_submit">Create Discussions</button>
        </form>
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...