Jump to content
  • 0

Module Edit Form Not Repopulate Fields


AllToolKits.com

Question

Hi,

 

In the home page of the module, i list all the server with it's details. It has an edit link. When clicking it, it's taking me to a  form to edit those server details, but i can't see the already existing details of the server.

 

the url of the edit page is http://mydomain.com/index.php/admin/settings/company/modules/editrow/7/5/,  where mydomain.com is blesta server domain.

 

 

Code snippet is below

    public function manageEditRow($module_row, array &$vars) {
        // Load the view into this object, so helpers can be automatically added to the view
        $this->view = new View("edit_row", "default");
        $this->view->base_uri = $this->base_uri;
        $this->view->setDefaultView("components" . DS . "modules" . DS . "snomone" . DS);
        
        // Load the helpers required for this view
        Loader::loadHelpers($this, array("Form", "Html", "Widget"));        
        $this->view->set("vars", (object)$vars);
        return $this->view->fetch();
    }

View

<?php
$this->Widget->clear();
$this->Widget->setLinkButtons(array());
$this->Widget->create($this->_("Mymodule.edit_row.box_title", true));

?>
<div class="inner">
    <?php
    $this->Form->create();
    ?>
    <div class="title_row first">
        <h3><?php $this->_("Mymodule.edit_row.module_title"); ?></h3>
    </div>
    <div class="pad">
        <ul>

            
            <li>
                <?php
                $this->Form->label($this->_("Mymodule.add_row.server_label", true), "server_label");
                $this->Form->fieldText("server_label", $this->Html->ifSet($vars->server_label));
                ?>
            </li>
            <li>
                <?php
                $this->Form->label($this->_("Mymodule.add_row.ip_address", true), "ip_address");
                $this->Form->fieldText("ip_address", $this->Html->ifSet($vars->ip_address));
                ?>
            </li>
            <li>
                <?php
                $this->Form->label($this->_("Mymodule.add_row.port", true), "port");
                $this->Form->fieldText("port", $this->Html->ifSet($vars->port));
                ?>
            </li>
            
            <li>
                <?php
                $this->Form->label($this->_("Mymodule.add_row.username", true), "username");
                $this->Form->fieldText("username", $this->Html->ifSet($vars->username));
                ?>
            </li>
            
             <li>
                <?php
                $this->Form->label($this->_("Mymodule.add_row.password", true), "password");
                $this->Form->fieldText("password", $this->Html->ifSet($vars->password));
                ?>
            </li>
        </ul>
    </div>


   

    <div class="button_row"><a class="btn_right submit" href="#"><?php $this->_("Mymodule.edit_row.add_btn"); ?></a></div>
        <?php
        $this->Form->end();
        ?>
</div>
<?php
$this->Widget->end();
?>

Form is coming without any values in it, why it's so? Can anyone help me?

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I fixed it :)

 

I thought $vars  will have the data, but it was not there.

 

So added below code

if (empty($vars))
            $vars = $this->formatModuleRowFields($module_row->meta);
private function formatModuleRowFields($module_row_meta) {

        foreach ($module_row_meta as $key => $value) {

                $fields[$key] = $value;
        }
        return $fields;
    }
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...