Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to make update form, that is going to retrieve the data for the specific ID selected, and fill in the form, so its going to be available for updating.

When I click edit on the specific entry (Product in my case), it takes me to the edit_product_view, but states the error "Trying to get property of non-object" for every variable that I use in set_values of the form elements.

Using print_r, I get the correct associative array, so it's passed correctly.

This is excerpt of my edit_product_view.

<h2><?php echo $heading; ?></h2>
<hr>
<table id="newproduct">
<?php echo form_open('products/edit/'.$product->id); ?>
<tr>
    <td class="label"><?php echo form_label('Name:');?></td>
    <td><?php echo form_input('prodname', set_value('prodname', $product->prodname));?></td>
</tr>
<tr>
    <td class="label"><?php echo form_label('Product Type:');?></td>
    <td><?php echo form_dropdown('ptname_fk', $product_types, set_value('ptname_fk', $product->ptname_fk));?></td>
</tr>

$product is the array holding all the key-value pairs, but I cannot fill the form for some reason.

Thank you in advance!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
227 views
Welcome To Ask or Share your Answers For Others

1 Answer

To access the elements in the array, use array notation: $product['prodname']

$product->prodname is object notation, which can only be used to access object attributes and methods.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...