Jump to content

Add custom field type to controller form


Recommended Posts

I'm developing a module who has a controller, this controller has a grid, and if I go to the registry's detail, I see a form, I need to put a custom field in that form. something like this: Group Button with bootstrap
 
this is my controller's code:
 
class ebayfollowcuentasController extends ModuleAdminController {

    public function __construct() {
        //.....
    }

    public function renderForm() {
        if (!($obj = $this->loadObject(true))) {
            return;
        }

        $this->fields_form=array(
            'legend' => array(
                'title' => $this->l('Accounts'),
                'icon' => 'icon-user'
            ),
            'input'=>array(
                //I need to put this field ↓
                'IdTipo'=>array(
                    'type'=>'buttonGroup',
                    'name'=>'IdTipo',
                    'label'=>$this->l('Store'),
                    'buttons'=>array(
                        array('label'=>'Button 1', 'url'=>'http://www.google.com'),
                        array('label'=>'Button 2', 'url'=>'http://www.bing.com'),
                        array('label'=>'Button 3', 'url'=>'http://www.yahoo.com'),
                    )
                ),

            ),
            'submit' => array('title' => $this->l('   Save   '), 'class' => 'button')
        );
        return parent::renderForm();
    }

}

I need to know how, and where do I need to put the template that render my field

Thanks a lot for any answers.

 

Link to comment
Share on other sites

In my Image/Video Gallery module, the file I use to override the default form and create a custom form is modules/gallerync/templates/admin/gallerync_images/helpers/form/form.tpl. Replace gallerync with the name of your module and gallerync_images with the table of your module and it should hopefully work. It's the following line in my __construct() function that sets the table:

        $this->table = 'gallerync_image';

Then my form.tpl like the following:

{extends file="helpers/form/form.tpl"}
{block name="input"}
    {if $input.type == 'select_category'}
        <select name="id_parent">
            {$input.options.html}
        </select>
    {else}
        {$smarty.block.parent}
    {/if}
{/block}

I hope this helps.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...