EllisLab text mark
Advanced Search
     
Lost parameter on form send
Posted: 20 November 2012 05:36 PM   [ Ignore ]
Joined: 2010-10-06
117 posts

Hi, I’m build a form dinamically in this way:

public function ppi() {
 $author_id 
$this->uri->segment(3);
 
$this->data_view['author'$this->Mauthor->getOne($author_id);
 
$this->data_view['ppi_data'$ppi_data $this->Mauthor->getFieldsName('autores_ppi');

 
$this->load->library('form_validation');
 
$this->form_validation->set_rules('NIVEL_ING''Nivel Ingenieril''trim|required');

 if (
$this->form_validation->run()) {
     print_r
($_POST);
     die();
 
}

 $this
->load->view('author/author_ppi'$this->data_view);

Then in my view I do this:

<p><strong>Autor NĂºmero:</strong<?php echo $author->ID_AUTOR ?></p>
 <
p><strong>Nombres:</strong<?php echo $author->NOMBRE ' ' $author->APELLIDO ?></p>
<?php foreach ($ppi_data as $value): ?>
     <?php 
if ($value != "ID_AUTOR_PPI"): ?>
  
<p><label><?php echo $value ?></label<?php echo form_error($value?> <input type="text" id="<?php echo $value ?>" name="<?php echo $value ?>" value="<?php echo set_value($value) ?>" class="text-long" /></p>
     
<?php endif; ?>
 <?php 
endforeach; ?> 

$this->uri->segment(3) always takes the author ID passed trough a view. When I show the form for first time all is fine but when I send the form leaving all fields empty I loose the ID from the URL and don’t know why and this cause this message:

A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: author/author_ppi.php

Line Number: 9

Nombres:
A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: author/author_ppi.php

Line Number: 10
A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: author/author_ppi.php

Line Number: 10

What I’m doing wrong?
PS: By the way does any knows a simple CRUD for CI? Not like Grocery and others just the basic CRUD

 
Posted: 20 November 2012 06:18 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2011-02-23
882 posts

Did you ensure that your model returns the correct data format? It looks like you are addressing attributes of your data row that are not available.
That’s either because your query returned an empty set or because the fields have different names. Btw: Are the field names all capitalized? Plus I cannot find a line 9 in either of your code snippets. Please provide more/all of your code so we can relate the error line to the line and can also determine whether the error actually originates from somewhere above wink

If you want a simple yet powerful MY_Model (which I guess is what your looking for if you don’t want something GroceryCRUD like) have a look at my MY_Model I am using since over a year. Has some bugs/features missing but the other things are quite powerful. Documentation is not separate but almost all methods have great documentation

https://github.com/ignitedcode/iCF/blob/develop/icf/core/ICF_Model.php

 Signature 

ignited Community Framework (WiP)  |  Read the User’s Guide. It won’t bite.

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

CI example .htaccess