Welcome Guest, Not a member yet? Register   Sign In
Input hidden
#11

[eluser]ibnclaudius[/eluser]
Are there any other field that is being sent correctly?
#12

[eluser]the_unforgiven[/eluser]
yes and sent to a controller function that is then sent to a model function tio insert in the db

Code:
Edit Client Form

<fieldset id="signin_menu">
      &lt;?php
    $attributes = array('class' => 'email', 'id' => 'loginform');
    echo form_open('admin/createmeeting', $attributes);
    
   echo form_hidden('CustomerID', $meeting->CustomerID);  // THIS IS WHAT I NEED TO GET TO THE DB
   $date = array('name' => 'MeetingDate', 'id' => 'date');
   $client = array(
       'name'        =>  'CustomerID',
             'value'       =>  $query->Contact1,
             'readonly'    => 'readonly'
   );
   ?&gt;
  
   <table>
    
    <tr><td>Date:</td><td>&lt;?php echo form_input($date); ?&gt;</td><td><small>Format: (month-day-year)</small></td></tr>
    <tr><td>Client:</td><td>&lt;?php echo form_input($client); ?&gt;</td><td>ClientID:</td><td>&lt;?php echo $meeting->CustomerID ?&gt;</td></tr>
  
    <tr><td>Remarks:</td><td>&lt;?php echo form_textarea('Remarks'); ?&gt;</td></tr>
    <tr><td>Cuttings:</td><td>&lt;?php echo form_textarea('Cuttings'); ?&gt;</td></tr>
    <tr><td>Date Entered:</td><td><strong>&lt;?php echo $query->DateEntered; ?&gt;</strong></td></tr>
   </table>
   &lt;?php echo form_submit('submit', 'Create New Meeting'); ?&gt;
   &lt;?php echo form_close();?&gt;
  
   </fieldset>
Code:
Controller

function createmeeting()
{
  // Form Validation
  $this->form_validation->set_rules('Date', 'Date', 'required');
  $this->form_validation->set_rules('Remarks', 'Remarks', 'required');
  $this->form_validation->set_rules('Cuttings', 'Cuttings', 'required');
  
  if ($this->form_validation->run() == FALSE)
  {
   // Activate the add meeting model
   $this->meeting_model->addNewMeeting();
  }
  else {
   echo 'Something wasnt right';
  }
}
Code:
Model

function addNewMeeting()
{
  $meeting = $this->getMeetingRows();
  
  $data = array(
       //'CustomerID'  => $meeting['CustomerID'],
    'CustomerID'  => $this->input->post('CustomerID'),
    'AgencyID'    => $this->input->post('AgencyID'),
    'MeetingDate' => $this->input->post('MeetingDate'),
    'Remarks'     => $this->input->post('Remarks'),
    'Cuttings'    => $this->input->post('Cuttings'),
    'DateEntered' => now()
  );

  $this->db->insert('tblmeeting', $data);
  $d['meeting'] = $this->session->set_flashdata('meeting', 'The meeting has been successfully saved');
  redirect('admin/updateclient/'.$meeting['CustomerID'], $d);
}
#13

[eluser]the_unforgiven[/eluser]
This is the view source:

Code:
<fieldset id="signin_menu">

      &lt;form action="http://localhost/ksd/admin/createmeeting" method="post" accept-charset="utf-8" class="email" id="loginform"&gt;
&lt;input type="hidden" name="CustomerID" value="3198" /&gt; &lt;!-- See the Customer ID is there--&gt;
  
   <table>
    
    <tr><td>Date:</td><td>&lt;input type="text" name="MeetingDate" value="" id="date"  /&gt;&lt;/td><td><small>Format: (month-day-year)</small></td></tr>
    <tr><td>Client:</td><td>&lt;input type="text" name="CustomerID" value="MR Webber" readonly="readonly"  /&gt;&lt;/td><td>ClientID:</td><td>3198</td></tr>
  
    <tr><td>Remarks:</td><td>&lt;textarea name="Remarks" cols="40" rows="10" &gt;&lt;/textarea></td></tr>

    <tr><td>Cuttings:</td><td>&lt;textarea name="Cuttings" cols="40" rows="10" &gt;&lt;/textarea></td></tr>
    <tr><td>Date Entered:</td><td><strong>1999-03-19 18:41:12</strong></td></tr>
   </table>
   &lt;input type="submit" name="submit" value="Create New Meeting"  /&gt;   &lt;/form&gt;      </fieldset>
#14

[eluser]ibnclaudius[/eluser]
Set $data in controller, and then send it to the model.

Code:
$data = array(
       //'CustomerID'  => $meeting['CustomerID'],
    'CustomerID'  => $this->input->post('CustomerID'),
    'AgencyID'    => $this->input->post('AgencyID'),
    'MeetingDate' => $this->input->post('MeetingDate'),
    'Remarks'     => $this->input->post('Remarks'),
    'Cuttings'    => $this->input->post('Cuttings'),
    'DateEntered' => now()
  );

$this->meeting_model->addNewMeeting($data);

Code:
function addNewMeeting($data)

#15

[eluser]the_unforgiven[/eluser]
i get

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: data

Filename: controllers/admin.php

Line Number: 355
#16

[eluser]ibnclaudius[/eluser]
You tried this?

Code:
function createmeeting()
{
  // Form Validation
  $this->form_validation->set_rules('Date', 'Date', 'required');
  $this->form_validation->set_rules('Remarks', 'Remarks', 'required');
  $this->form_validation->set_rules('Cuttings', 'Cuttings', 'required');
  
  if ($this->form_validation->run() == FALSE)
  {
    $data = array(
       //'CustomerID'  => $meeting['CustomerID'],
    'CustomerID'  => $this->input->post('CustomerID'),
    'AgencyID'    => $this->input->post('AgencyID'),
    'MeetingDate' => $this->input->post('MeetingDate'),
    'Remarks'     => $this->input->post('Remarks'),
    'Cuttings'    => $this->input->post('Cuttings'),
    'DateEntered' => now()
  );

   $this->meeting_model->addNewMeeting($data); // <= HERE!
  }
  else {
   echo 'Something wasnt right';
  }
}

Code:
function addNewMeeting($data) // <= HERE!
{
  $meeting = $this->getMeetingRows();

  $this->db->insert('tblmeeting', $data);
  $d['meeting'] = $this->session->set_flashdata('meeting', 'The meeting has been successfully saved');
  redirect('admin/updateclient/'.$meeting['CustomerID'], $d);
}
#17

[eluser]the_unforgiven[/eluser]
Yes thats exactly what ive done Wink
#18

[eluser]ibnclaudius[/eluser]
Try this, and show me what you got:

Code:
function createmeeting()
{
  // Form Validation
  $this->form_validation->set_rules('Date', 'Date', 'required');
  $this->form_validation->set_rules('Remarks', 'Remarks', 'required');
  $this->form_validation->set_rules('Cuttings', 'Cuttings', 'required');
  
  if ($this->form_validation->run() == FALSE)
  {
    $data = array(
       //'CustomerID'  => $meeting['CustomerID'],
    'CustomerID'  => $this->input->post('CustomerID'),
    'AgencyID'    => $this->input->post('AgencyID'),
    'MeetingDate' => $this->input->post('MeetingDate'),
    'Remarks'     => $this->input->post('Remarks'),
    'Cuttings'    => $this->input->post('Cuttings'),
    'DateEntered' => now()
  );

    var_dump($data);
  }
  else {
   echo 'Something wasnt right';
  }
}
#19

[eluser]the_unforgiven[/eluser]
Heres the output

Code:
array(6) { ["CustomerID"]=> string(16) "MR Webber" ["AgencyID"]=> bool(false) ["MeetingDate"]=> string(10) "01/01/1888" ["Remarks"]=> string(16) "is trhis working" ["Cuttings"]=> string(25) "kjhsfkjh dflkjd flkjd fdf" ["DateEntered"]=> int(1328049108) }
#20

[eluser]ibnclaudius[/eluser]
Change:
Code:
var_dump($data);
For:
Code:
$this->meeting_model->addNewMeeting($data);

Add this right after defining the class of your controller:
Code:
var $data;

Now, try to run...




Theme © iAndrew 2016 - Forum software by © MyBB