Edit Form not showing

i’m creating edit form. but the form not showing.
this is the screenshoot.

this is my code in controller.

public function editAction()
{
    // Get the requested page.
    $data = $this->_helper->db->findById();
    $form = $this->_getForm($data);

    //print_r($data);exit();
    $this->view->form = $form;
    $this->_processPageForm($data, $form, 'edit');
}

protected function _getForm($data = null)
{ 
    $formOptions = array('type' => 'config_dir_data');
    if ($data && $data->exists()) {
        $formOptions['record'] = $data;
    }
    
    $form = new Omeka_Form_Admin($formOptions);
    $form->addElementToEditGroup(
        'select', 'item_id',
        array(
            'id' => 'config-dir-item-id',
            'multiOptions' => config_dir_item_options(),
            'value' => $data->item_id,
            'label' => __('Item'),
            'required' => true
        )
    );
    $form->addElementToEditGroup(
        'textarea', 'description',
        array(
            'id' => 'config-dir-description',
            //'cols'  => 10,
            'rows'  => 15,
            'value' => $data->description,
            'label' => __('Deskripsi'),
            'required' => true
        )
    );
    
    $form->addElementToEditGroup(
        'text', 'path',
        array(
            'id' => 'config-dir-path',
            'value' => $data->path,
            'label' => __('Path'),
            'required' => true
        )
    );

    if (class_exists('Omeka_Form_Element_SessionCsrfToken')) {
        $form->addElement('sessionCsrfToken', 'csrf_token');
    }
    
    return $form;
}

How i fix it?please help. thanks

What does the view file look like?

You could have everything set up right in the controller and still get this if your view doesn’t print the form onto the page.

thanks for your response john. this is the code on view.

<?php $head = array('bodyclass' => ' primary', 'title' => html_escape(__('Konfigurasi Direktori | Tambah Konfigurasi'))); echo head($head); ?> <?php echo flash(); ?> <?php echo $form; ?> <?php echo foot(); ?>

is that something wrong?

Nothing looks obviously wrong to me.

Have you tried turning on error messages?

Yes, i have. But no error message.
Besides on controller and view. Should i look onto model?

What does _processPageForm in your controller do? You call it but haven’t shown the code for it.

1 Like

ooh oke. this the code in _processPageForm

private function _processPageForm($data, $form, $action)
{
// Set the page object to the view.
$this->view->config_dir_data = $data;

    if ($this->getRequest()->isPost()) {
        if (!$form->isValid($_POST)) {
            $this->_helper->_flashMessenger(__('There was an error on the form. Please try again.'), 'error');
            return;
        }
        $cd=get_record('ConfigDirData', array('advanced'=>array('item_id' => $_POST['item_id'])));
        if ($cd && 'add' == $action) {
            $i=get_record('Item', array('advanced'=>array('id' => $cd->item_id)));
            $in=metadata($i,array('Dublin Core','Title'));
             $this->_helper->_flashMessenger(__('Item '.$in.' sudah mempunyai direktori penyimpanan. Anda dapat edit untuk mengubah direktori penyimpanan.'), 'error');
        }else{
            try {
                $data->setPostData($_POST);
                if ($data->save()) {

                    if ('add' == $action) {
                        $path = '../files/'.$data->path_encript;
                        mkdir($path,0777,true);
                        $this->_helper->flashMessenger(__('The page "%s" has been added.', $data->description), 'success');
                    } else if ('edit' == $action) {
                        /*$path = '../files/'.$data->path_encript;
                        mkdir(pathname)*/
                        $this->_helper->flashMessenger(__('The page "%s" has been edited.', $data->description), 'success');
                    }
                    
                    $this->_helper->redirector('browse');
                    return;
                }
            // Catch validation errors.
            } catch (Omeka_Validate_Exception $e) {
                $this->_helper->flashMessenger($e);
            }
        }
    }
}

it still not showing. i created this form in my plugin. please help

Halo john please help

So here’s the problem: we know you’re not hitting a fatal error, because the footer of the page is showing, so the execution is continuning on through to your call to foot() in the view.

This would seem to mean that $form in your view isn’t what you think it is. Maybe you should use a var_dump or a debugger to see what’s actually in that variable.

John this is an array in $form variable.

That output looks pretty much like it should. But when you just echo $form instead, it’s just blank?

Yes john, just blank. To create that form just in controller and view, right?or i should look to other?like in model maybe?

Have you checked the inspector or view source to see if there’s anything at all being printed? (like an empty <form>, or maybe more than that just being hidden with CSS)