Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter Form Helper problem
#1

[eluser]RaGe10940[/eluser]
I have a table that each row must have an action *delete or start* my problem is that when I choose my options and hit submit the form does not submit.

The view :

Code:
<table id='waiting' class='display'>
                <thead>
                    <tr>
                        <th>ID</th>                      
                        <th>A Number</th>
                        <th>First Name</th>
                        <th>Last Name</th>
                        <th>Reason for visit</th>
                        <th>Comments</th>
                        <th>Aid Year</th>
                        <th>Staff Comments</th>
                        <th>Staff Member</th>
                     <th>Options</th>
                    </tr>
                </thead>
                <tbody>
     &lt;?php foreach ($waiting as $row) { ?&gt;                
     <tr>
      <td>&lt;?php echo htmlspecialchars($row['id'], ENT_QUOTES, 'UTF-8'); ?&gt;</td>    
      <td>&lt;?php echo anchor('studentqueue_controller/history', htmlspecialchars($this->encrypt->decode($row['anum']), ENT_QUOTES, 'UTF-8'), 'target="_blank"'); ?&gt;</td>
      <td>&lt;?php echo htmlspecialchars($row['first'], ENT_QUOTES, 'UTF-8'); ?&gt;</td>
      <td>&lt;?php echo htmlspecialchars($row['last'], ENT_QUOTES, 'UTF-8'); ?&gt;</td>
      <td>&lt;?php echo htmlspecialchars($row['reason'], ENT_QUOTES, 'UTF-8'); ?&gt;</td>
      <td>&lt;?php echo htmlspecialchars($row['studentcomments'], ENT_QUOTES, 'UTF-8'); ?&gt;</td>
      <td>&lt;?php echo htmlspecialchars($row['aidyear'], ENT_QUOTES, 'UTF-8'); ?&gt;</td>
      <td>&lt;?php echo htmlspecialchars($row['counselorcomments'], ENT_QUOTES, 'UTF-8'); ?&gt;</td>
      <td>
       &lt;?php echo form_open('studentqueue_controller/counselorscreen'); ?&gt;
       &lt;?php echo form_dropdown('namedrop', $names) ?&gt;</td>
      <td>
       &lt;input type="checkbox" name="options" value="start" &lt;?php echo form_checkbox('options','start') ?&gt;Start&lt;/input>
       &lt;input type="checkbox" name="options" value="stop" &lt;?php echo form_checkbox('options','stop') ?&gt;Delete&lt;/input>
      </td>
     </tr>
     &lt;?php } ; ?&gt;
     &lt;?php echo form_submit('submit', 'Start Action'); ?&gt;
     &lt;?php echo form_close(); ?&gt;
    
                </tbody>    
            </table>

The form open is in the for each loop since each row has its own ID and can not be used by another row. However the submit and form close buttons are out side of the loop.

I hope some one sees something that I dont.

Thanks,
#2

[eluser]Jan_1[/eluser]
your checkboxes a little bit messy... but how about this as a hint:

Code:
<table id='waiting' class='display'>
<thead>
  <tr>
     <th>ID</th>                      
     ... etc
     </tr>
  </thead>
<tbody>
&lt;?php
$i=0;
echo form_open('studentqueue_controller/counselorscreen');
foreach ($waiting as $row)
{
?&gt;                
     <tr>
     <td>&lt;?php echo htmlspecialchars($row['id'], ENT_QUOTES, 'UTF-8'); ?&gt;</td>    
     ... etc
     <td>&lt;?php echo htmlspecialchars($row['counselorcomments'], ENT_QUOTES, 'UTF-8'); ?&gt;</td>
     <td>&lt;?php echo form_dropdown('namedrop', $names) ?&gt;</td>
      <td>&lt;input type="checkbox" name="start[&lt;?=$i?&gt;]" value="$row['id']"&gt;Start</td>
      <td>&lt;input type="checkbox" name="delete[&lt;?=$i?&gt;]" value="$row['id']"&gt;Delete</td>
     </tr>
&lt;?php
}
echo form_submit('submit', 'Start Action'); ?&gt;
echo form_close();
?&gt;
</tbody>    
</table>

and in studentqueue_controller
Code:
function counselorscreen()
if ($this->form_validation->run() == FALSE)
  {
   load formular view (again)
  }
  else
  {
                     $starter = $this->input->post('start');
                     foreach($starter as $start){  do something  }
  }

or maybe use
Code:
<td>&lt;?=anchor("controller/function/".$row['id'], "<i class='icon-remove'></i>")?&gt;</td>
(with nice icons from twitter/bootstrap)
if you want to have different things in the row

Hope it's a help. have a nice weekend!
#3

[eluser]RaGe10940[/eluser]
Code:
<h3>Students Waiting</h3>
            <table id='waiting' class='display'>
                <thead>
                    <tr>
                        <th>ID</th>                      
                        <th>A Number</th>
                        <th>First Name</th>
                        <th>Last Name</th>
                        <th>Reason for visit</th>
                        <th>Comments</th>
                        <th>Aid Year</th>
                        <th>Staff Comments</th>
                        <th>Staff Member</th>
                     <th>Options</th>
                    </tr>
                </thead>
                <tbody>
    
     &lt;?php
     foreach ($waiting as $row)
     {
      ?&gt;                
     <tr>
      <td>&lt;?php echo htmlspecialchars($row['id'], ENT_QUOTES, 'UTF-8'); ?&gt;</td>    
      <td>&lt;?php echo anchor('studentqueue_controller/history/'.urlencode($row['anum']). '', $row['anum'], 'target="_blank"'); ?&gt;</td>
      <td>&lt;?php echo htmlspecialchars($row['first'], ENT_QUOTES, 'UTF-8'); ?&gt;</td>
      <td>&lt;?php echo htmlspecialchars($row['last'], ENT_QUOTES, 'UTF-8'); ?&gt;</td>
      <td>&lt;?php echo htmlspecialchars($row['reason'], ENT_QUOTES, 'UTF-8'); ?&gt;</td>
      <td>&lt;?php echo htmlspecialchars($row['studentcomments'], ENT_QUOTES, 'UTF-8'); ?&gt;</td>
      <td>&lt;?php echo htmlspecialchars($row['aidyear'], ENT_QUOTES, 'UTF-8'); ?&gt;</td>
      <td>&lt;?php echo htmlspecialchars($row['counselorcomments'], ENT_QUOTES, 'UTF-8'); ?&gt;</td>
      <td>
       &lt;?php echo form_open('studentqueue_controller/counselorscreen'); ?&gt;
       &lt;?php echo form_dropdown('namedrop', $names) ?&gt;</td>
      <td>
       &lt;input type="checkbox" name="options" value="start" &lt;?php echo form_checkbox('options','start') ?&gt;Start&lt;/input>
       <br />
       &lt;input type="checkbox" name="options" value="stop" &lt;?php echo form_checkbox('options','stop') ?&gt;Delete&lt;/input>
       &lt;?php echo form_submit('submit', 'Start Action'); ?&gt;      
       &lt;?php echo form_close(); ?&gt;
      </td>
     </tr>
    
     &lt;?php
      } ?&gt;
                </tbody>    
            </table>

I put form_open and form close in each of the rows. that works just fine now. thanks for the input!




Theme © iAndrew 2016 - Forum software by © MyBB