• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
add and edit in one view

#1
[eluser]mardon[/eluser]
Hi, I want add and edit records in db in one view
Code:
<div id="addcert_form">
    &lt;?php
    echo $akce;
    if ($akce == 'add') {
        echo form_open('admin/add_cert');
    }
    else {
        echo form_open('admin/edit_cert/'.$id);
    }
    echo $ser_cislo;
    ?&gt;
    <ul>
        <li>
            <label>Sériové číslo:</label>
            <div>
&lt;?php echo form_input(array('id' => 'ser_cislo', 'name' => 'ser_cislo', 'value'=>$ser_cislo)); ?&gt;
            </div>
        </li>
        <li>
            <label>Počátek platnosti:</label>
            <div>
&lt;?php echo form_input(array('id' => 'pocatek', 'name' => 'pocatek','value'=>$pocatek)); ?&gt;
            </div>
        </li>
        <li>
            <label>Konecplatnosti:</label>
            <div>
&lt;?php echo form_input(array('id' => 'konec', 'name' => 'konec','value'=>$konec)); ?&gt;
            </div>
        </li>
        <li>
            <label>Uživatel:</label>
            <div>
&lt;?php echo form_dropdown('id_user', $options, '1'); ?&gt;
            </div>
        </li>
        <li>
            &lt;?php
            if ($this->session->flashdata('login_error')) {
                echo "Nesprávné přihlašovací údaje";
            }
            echo validation_errors();
            ?&gt;
        </li>
        <li>
&lt;?php
if ($akce == 'add')
echo form_submit(array('name' => 'submit'), 'Přidat');
else echo form_submit(array('name' => 'submit'), 'Uložit');?&gt;
        </li>
    </ul>

but I have problem with value in input form when I add a record the value isnt set.
Its bad idea to have one form for add and edit? How to solve my problem?


Messages In This Thread
add and edit in one view - by El Forum - 04-04-2011, 07:34 AM
add and edit in one view - by El Forum - 04-04-2011, 12:27 PM
add and edit in one view - by El Forum - 04-04-2011, 11:47 PM
add and edit in one view - by El Forum - 04-05-2011, 12:14 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.