Jump to content

Search the Community

Showing results for tags 'of(false)'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 1 result

  1. Hi guys, have been struggling all day with a problem creating a front-end form. The idea is that "students" are linked with "feedback" and on both templates there is a page field which links the two together. The superuser has an update feedback form on the frontend where they can make changes, set to hidden/visible as well as assigning the feedback to a student. For some reason I can get the feedback page itself to be updated, I can remove any old attachments from student pages to this feedback page but trying to update the new student to be attached is causing errors. I've had an error telling me to set OutputFormatting to false (it already is) and now I seem to be getting server errors that it's running out of time. I've included the current commented code below, can anyone see anything I'm missing? Thanks <?php // If form is submitted if ($input->post->submit_update_testimonial) { // Assign empty variables $out = ""; $error = 0; // Check if required fields empty if (empty($input->post->title) || empty($input->post->testimonial)) { $error = 1; $out = "<h3>Please include a title and testimonial</h3>"; } if ($error == 0) { // Set sanitized variables $title = $sanitizer->text($input->post->title); $testimonial = $sanitizer->textarea($input->post->testimonial); $date = $sanitizer->text($input->post->date); $student = $sanitizer->text($input->post->student); // Get current student who is attached to feedback (if any) and remove the attachment $current_s = $pages->get("template=student, student_feedback=$page"); if ($current_s->id) { $current_s->of(false); $current_s->student_feedback = ""; $current_s->save(); } // See if newly-selected student exists and if so attach it to this feedback (CAUSING ERRORS) $new_s = $pages->get("template=student, id=$student"); if ($new_s->id) { $new_s->of(false); $new_s->set("student_feedback", $student); $new_s->save(); } // Update the actual feedbcak contents from the form $page->of(false); $page->title = $title; $page->body = $testimonial; $page->testimonial_date = $date; // Update whether the feedback should be visible or hidden if ($input->post->publish == "") { $page->addStatus(Page::statusHidden); } else { $page->removeStatus(Page::statusHidden); } // If set to a student then assign it on the feedback page if ($student == "unassigned") { $page->set("feedback_which_student", ""); } else { $page->feedback_which_student = $student; } $page->save(); } // end if no errors } // end if form submitted ?> <?php if(!$user->isGuest() && $user->name === $page->name OR $user->isSuperuser() OR $user->hasRole("editor")) { include("./header.inc"); ?> <div id="feedback_item_admin" class="content"> <div class="row"> <div class="large-12 columns"> <div class="content_area"> <div class="row"> <div class="large-9 columns"> <h3>Edit Testimonial</h3> </div> <!-- /.large-9 columns --> <div class="large-3 columns"> <a href="<?php echo $page->parent->url; ?>" class="tar flr">← Return to Testimonials</a> </div> <!-- /.large-3 columns --> </div> <!-- /.row --> <hr> <form action="./" method="post"> <div class="row"> <div class="large-8 columns"> <input type="text" name="title" value="<?php echo $page->title; ?>"> </div> <!-- /.large-8 columns --> <div class="large-4 columns"> <input type="date" name="date" value="<?php echo date('Y-m-d', strtotime($page->testimonial_date)); ?>"> </div> <!-- /.large-4 columns --> </div> <!-- /.row --> <textarea name="testimonial" cols="30" rows="10"><?php echo strip_tags($page->body); ?></textarea> <div class="row"> <div class="large-6 columns"> <label for="publish">Publish?</label> <input type="checkbox" name="publish"<?php if (!$page->is(Page::statusHidden)) { echo " checked"; } ?>> </div> <!-- /.large-6 columns --> <div class="large-6 columns"> <label for="student">Relates to student?</label> <select name="student"> <?php if ($page->feedback_which_student->id != "") { ?> <option value="<?php echo $page->feedback_which_student->id; ?>"><?php echo $page->feedback_which_student->title; ?></option> <?php } ?> <?php foreach ($pages->find("template=student")->remove($page->feedback_which_student) as $student) { ?> <option value="<?php echo $student->id; ?>"><?php echo $student->title; ?></option> <?php } ?> <option value="unassigned"<?php if ($page->feedback_which_student->id == "") { echo " selected"; } ?>>Unassigned</option> </select> </div> <!-- /.large-6 columns --> </div> <!-- /.row --> <input class="button secondary small drop_down" type="submit" name="submit_update_testimonial" value="Update"> </form> </div> </div> </div> <?php include("./footer.inc"); ?> <?php } else { throw new Wire404Exception(); }
×
×
  • Create New...