<h2><?= ucfirst($this->site['edycja_elementu']);?></>:</h2>
<?php
    if(isset($message))
        echo '<p>'.$message.'</p>';


?>
<form action="" method="post" enctype="multipart/form-data">
    <input type="hidden" name="id" value="<?php echo ($list_item->id); ?>"/>
    <table>
        <tr>
            <td>Kategoria nadrzędna</td>
            <td>
                <select name="parent_id">
                    <option value=""></option>
                    <?php
                        if(!empty($lists) && is_array($lists))
                            foreach($lists as $k=>$v)
                            {
                                if($v->id == $list_item->id)
                                    continue;
                                
                                echo '<option value="'.$v['id'].'" '.(($v['id'] == $list_item->parent_id) ? "selected=\"selected\"":"").'>'.$v['name'].'</option>';
                            }
                    ?>
                </select>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('parent_id'); ?></td>
        </tr>

        <tr>
            <td>Nazwa</td>
            <td>
                <input type="text" name="name" value="<?php echo (empty($list_item->name) ? set_value('name'):$list_item->name); ?>"/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('name'); ?></td>
        </tr>


        <tr>
            <td>Opis</td>
            <td>
                <textarea name="description"><?php echo (empty($list_item->description) ? set_value('description'):$list_item->description); ?></textarea>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('description'); ?></td>
        </tr>


        <tr>
            <td>Kolejność</td>
            <td>
                <input type="text" name="show_order" value="<?php echo (empty($list_item->show_order) ? set_value('show_order'):$list_item->show_order); ?>"/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('show_order'); ?></td>
        </tr>

        <tr>
            <td>Link</td>
            <td>
                <input type="text" name="link" value="<?php echo (empty($list_item->link) ? set_value('link'):$list_item->link); ?>"/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('link'); ?></td>
        </tr>


        <tr>
            <td>Obrazek</td>
            <td>
                <input type="file" name="image" value="<?php echo set_value('image') ?>"/>
                <br/><a href="/admin/delete_list_item_image/<?php echo $list_item->id; ?>">usuń obrazek</a>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('image'); ?></td>
        </tr>


        <tr>
            <td>Galeria</td>
            <td>
                <select name="id_galleries">
                    <option value=""></option>
                    <?php
                        if(!empty($galleries) && is_array($galleries))
                            foreach($galleries as $k=>$v)
                                echo '<option value="'.$v['idgalleries'].'" '.(($v['idgalleries'] == set_value('id_galleries') || $v['idgalleries'] == $list_item->id_galleries)  ? "selected=\"selected\"":"").'>'.$v['title'].'</option>';
                    ?>
                </select>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('id_galleries'); ?></td>
        </tr>

        <tr>
            <td>Atrybut 1</td>
            <td>
                <input type="text" name="param1" value="<?php echo (empty($list_item->param1) ? set_value('param1'):$list_item->param1); ?>"/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('param1'); ?></td>
        </tr>

        <tr>
            <td>Atrybut 2</td>
            <td>
                <input type="text" name="param2" value="<?php echo (empty($list_item->param2) ? set_value('param2'):$list_item->param2); ?>"/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('param2'); ?></td>
        </tr>

        <tr>
            <td>Atrybut 3</td>
            <td>
                <input type="text" name="param3" value="<?php echo (empty($list_item->param3) ? set_value('param3'):$list_item->param3); ?>"/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('param3'); ?></td>
        </tr>

        <tr>
            <td>Atrybut 4</td>
            <td>
                <input type="text" name="param4" value="<?php echo (empty($list_item->param4) ? set_value('param4'):$list_item->param4); ?>"/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><?php echo form_error('param4'); ?></td>
        </tr>

        <tr>
            <td></td>
            <td><input type="submit" value="Zatwierdź"/></td>
            <td></td>
        </tr>
    </table>
</form>
<script type="text/javascript">
    window.onload = function()
    {
        var oFCKeditor = new FCKeditor( 'description' ) ;
        oFCKeditor.Height = '300' ;
        oFCKeditor.Width = '600' ;
        oFCKeditor.BasePath = "/files/fckeditor/" ;
        oFCKeditor.ReplaceTextarea() ;
    }
</script>