Welcome Guest, Not a member yet? Register   Sign In
Questionnaire submission results in an empty page.
#1

This code was thrown at me. I know almost nothing about Code Ignitor and just a bit about PHP. I have a form that returns a value that I specify. When I click the submit button, it takes me back to the correct page, but there is no code on it. I'm stumped as to what's causing the problem. The claim does not appear to be entering the database by establishing the user id, thus I doubt it gets that far. What more can I try?
The form:

Code:
<form method="post" action="/sp/makeClaim">
  <div class="text-center" style="padding-bottom: 20px;">
    <select name="spId">
      <option value="-1"<?php $this->printSelected($spId, -1);?>>-- Choose a Service Provider --</option>
      <?php
      foreach ($spData as $id => $name)
      {
        ?>
        <option value="<?php echo $id; ?>"<?php $this->printSelected($spId, $id);?>><?php print($name); ?></option>
      <?php
      }
      ?>
    </select>
  </div>

  <div class="text-center">
    <input type="submit" class="btn btn-default sp" value="Make Claim from List Above" /><br />
    or<br />
    <a href="/sp/create/" class="btn btn-default sp">Add Your Service Provider Information</a>
  </div>
</form>


The Controller code:


public function makeClaim()
{
  $formDefaults = array(
    'spId' => -1
  );

  if ($this->input->post())
  {
    foreach ($formDefaults as $key => $defaultValue)
    {
      $$key = trim($this->input->post($key));

      if ($spId == -1)
      {
        $this->addError('You must choose the service provider you wish to claim.');
      }
    }

    $sp = $this->getEm()->getRepository('Entities\ServiceProvider')->findOneBy(array('id' => $spId));
    if (is_null($sp))
    {
      $this->addError('A service provider with that ID could not be found.');
    }

    if (count($this->getErrors()) == 0)
    {
      $claim = new \Entities\Claim();
      $claim->setUser($this->getUser());
      $claim->setSP($sp);
      $claim->setStatus('New');
      $claim->setLastUpdated(new DateTime(date('Y-m-d H:i:s')));
      $claim->setLastUpdatedBy($this->getUser()->getRealName() . ' (' . $this->getUser()->getId() . ')');

      $this->em->persist($claim);
      $this->em->flush();
      $this->_redirect(true, 'Your claim on that service provider account has been submitted for review. We will contact you with a status update after we review your request.', '/sp/makeClaim/');
    }
Reply
#2

In the code, $this->_redirect() should send a notification or call $this->get Error() in HTML.
Try to find the code in another controller|template that shows the results
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB