2

I am using the same view page for both submitting data to database and editing. When I submit the form all the elements go to database. When editing the input field contains the item to edit but the dropdown form doesnot load and displays error saying $expensetype not defined. the $expensetype is passed through the controller to the form. I am developing in pyrocms. Pyrocms is developed in Codeigniter.

<li>
        <label for="expense_type_id">Expense Type</label> <!--        expense_type_id-->
    <div class="input">
        <?php echo form_dropdown("expense_type_id",$expensetype, set_value("expense_type_id", $expense_type_id)); ?>
    </div>
    </li><li>
        <label for="expense_rs">Expense(NRS)</label> <!--        expense_rs-->
    <div class="input">
        <?php echo form_input("expense_rs", set_value("expense_rs", $expense_rs)); ?>
    </div>
    </li>

How to make the dropdown to show the item while editing.

nzy
  • 854
  • 2
  • 15
  • 28
  • Can you show how you are defining "expensetype" in the controller and how you are passing it to the view? What I usually do is add an "echo" at the beginning of the view to see if the variable is present. If not, then go back to the controller and find the issue there. If you are pulling it from the DB, it seems like you are adding a field named "expense_type_id", but you are trying to use "expensetype". Are you changing the field name in the controller? – Thom Mar 23 '15 at 15:01
  • Another thing I do is put all pulled data into an array called "$form". Then you can reference them using $form['expense_type_id']. The advantage to this is that you can print the array $from at the top of the view so you can see what fields you have and their names. Hope this help! – Thom Mar 23 '15 at 15:01

0 Answers0