⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

empty field getting stuck when submitting add form



ded
  • profile picture
  • Member

Posted 15 April 2014 - 02:11 AM

Hi guys,

 

I have in the "add form" the fields "fake_conhece_pessoa_01" and "fake_conhece_pessoa_02". These values are not shown in the table, they are in the add form 'cause I use a callback_after_insert to insert these values in another the table. These fields are also displayed with set_relation - they "receive" the fullname of all people registered in another table. Everything works well when I select a person in each of these fields, but when I left one of the fields empty (or both empty) and click "Save and go back to list", the user is not redirected to the list page. In fact, if I select a person in one of these fields and left the other one empty, the user is not redirect BUT the value of the field that was filled IS added to that other table.

 

Any clues?

 

I tried to follow this topic with no advance: /topic/324-workaround-redirect-to-the-list-after-insertupdate-without-changing-the-core-functionality-of-gc/

 

The codes:

 

function pessoa_management()
{
$crud = new grocery_CRUD();


$crud->set_table('pessoa');
$crud->set_subject('Pessoa');
$crud->set_lang_string('list_add','Adicionar');
$crud->columns('pessoa_link','nome_completo','cidade_natal');
$crud->fields('pessoa_link','nome_completo','cidade_natal','fake_conhece_pessoa_01','fake_conhece_pessoa_02');
$crud->required_fields('pessoa_link','nome_completo','cidade_natal');


$crud->display_as('pessoa_id','Pessoa ID')
->display_as('pessoa_link','Pessoa URL')
->display_as('nome_completo','Nome Completo')
->display_as('cidade_natal','Cidade Natal')
->display_as('fake_conhece_pessoa_01','Pessoa Conhecida 01')
->display_as('fake_conhece_pessoa_02','Pessoa Conhecida 02');


$crud->set_relation('fake_conhece_pessoa_01','pessoa','nome_completo');
$crud->set_relation('fake_conhece_pessoa_02','pessoa','nome_completo');


$output = $crud->render();


$this->_redesocial_output($output);
}

 

function fconhece($post_array, $primary_key)
{
$user_logs_insert01 = array("pessoa_id" => $primary_key, "pessoa_conhecida_id" => $post_array['fake_conhece_pessoa_01']);
$user_logs_insert02 = array("pessoa_id" => $primary_key, "pessoa_conhecida_id" => $post_array['fake_conhece_pessoa_02']);


$this->db->insert('conhece',$user_logs_insert01);
$this->db->insert('conhece',$user_logs_insert02);


return true;
}