Display bd record by id in a modal Foundation 5 (pop-up)

Asked

Viewed 150 times

1

The frameworks I’m using are the Zurb Foundation 5 and the Codeigniter.

How to display on a modal Foundation 5 database information per ID? I’ve actually performed the procedure, only I can’t display the record per ID.

Displaying records with the Modal Reveal link:

 <?php
    $query = $this->protocolo->get_all_protocolo()->result();
    foreach ($query as $linha):
        echo '<tr>';
        printf('<td class="text-center">%s</td>', $linha->id);
        printf('<td class="text-center">%s</td>', $linha->nome);
        printf('<td class="text-center">%s</td>', $linha->numerodocumento);
        printf('<td class="text-center">%s</td>', anchor("protocolo/gerenciar/$linha->id", 'Observação', 'data-reveal-id="firstModal"'));
        printf('<td class="text-center">%s</td>', anchor('#', 'Detalhes', 'class="addimg"'));
        printf('<td class="text-center">%s</td>', 'Status');                
        echo '</tr>';
    endforeach;
 ?>

Form:

 <?php
    $iduser = $this->uri->segment(3);
    $querys = $this->protocolo->get_byid($iduser)->row();
    echo '<div id="firstModal" class="reveal-modal small" data-reveal>';
    echo '<div class="row">';
    echo '<div class="small-8 columns">';
    echo form_open('#');
    echo form_fieldset('Observação');
    echo form_label('Protocolo');
    echo form_input(array('name' => 'protocolo', 'class' => 'five', 'disabled' => 'disabled'), set_value('protocolo', $querys->id));
    echo form_label('Observação');
    echo form_textarea(array('name' => 'texto', 'class' => 'five'));
    echo '<div class="row">';
    echo '<div class="small-2 columns">';
    echo form_submit(array('name' => 'cadastrar', 'class' => 'button radius small font'), 'Salvar dados');
    echo '</div>';
    echo '</div>';
    echo '</div>';
    echo '</div>';
    echo '<a class="close-reveal-modal">&#215;';
    echo '</div>';
    break;

This way it presents me an error when I go to the manage screen(locahost/system/protocol/manage):

Fatal error: Call to a Member Function Row() on a non-object.

I believe this error is because I am calling a modal that has a parameter, in this case the user id. How can I solve this problem?

  • Andrew in my experience what’s happening is that the get_byid($iduser) is returning false or null. See what the result of this function is var_dump($this->protocolo->get_byid($iduser)) and see the result.

1 answer

0

Let’s look at the error:

Fatal error: Call to a Member Function Row() on a non-object.

The mistake says row() is being called in a non-eobject, which would be the protocol sought through the method $this->protocolo->get_byid($iduser). Of the two, one:

  • The variable $iduser is not being received in the modal, or

  • The variable $iduser is being received, but there is no protocol with this number.

Also, there’s the fact that $iduser comes from the URL, through the call $this->uri->segment(3). See if in fact this is the best way to get the URI value.

  • I made a condition in the $iduser variable and the error came out. But now the modal appears two problems: first, when I first click on the link the protocol/manage/2 url is called, however, the modal does not appear in this first click, only from the second. The second problem is, when I click the same link for the second time to run the modal, the url always remains the same in other links, for example, if I run/manage/2 protocol, when I click on another/manage/3 protocol link, it shows me the previous one, at all links!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.