Jump to content

Questions about Helper Forms


theillo

Recommended Posts

There are a few things I don't understand about the helper class, and I have a few questions on how to do some things (if even doable)

 

1.)

First of all, what do these lines of code do:

$helper->module = $this;
$helper->name_controller = $this->name;
$helper->title = $this->displayName; //this is any string, but I don't know where it shows up.
$helper->show_toolbar = false; //makes no difference to me if on or off. 
$helper->table = $this->table; //this variable is from the parent class, no idea what it does.
$helper->identifier = $this->identifier; //this variable is from the parent class, no idea what it does.

2.)

Next, what does this do, and what is the difference between the two? (I have gotten both lines from official prestashop resources: Either the getting started documentation or the module generator).

$helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name;

$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false);

3.)

The next question, I think I know what it does, but I am not sure

$helper->submit_action = 'submit'.$this->name;

Will this enable me to use this?

if (Tools::isSubmit('submit'.$this->name))
{
    //do stuff
}

4.)

Now when making the submit buttons, I saw it's possible to do

'submit' => array(
	'title' => $this->l('Create'),
	'icon' => 'process-icon-import',
)

By default the icon is a floppy disc. What other icons are there? They are not named according to the font awesome icons...

 

5.)

and lastly:

Is there a way to segment my forms?

 

I can make "legends" for my forms, small title bars, by doing this in my form field array:

'legend' => array(
   'title' => $this->l('Gear Wheels, yay!'),
   'icon' => 'icon-cogs',
),

But I can only have one of those per submit button, because my form array is defined like this:

'form' => array(
	'legend' => array(
	'title' => $this->l('Gear Wheels, yay!'),
	'icon' => 'icon-cogs',
	),
	'input' => array(						
		array(
			'col' => 3,
			'type' => 'text',
			'prefix' => '<i class="icon icon-user"></i>',
			'name' => 'your_name',
			'label' => $this->l('Your name'),
		)					
	),
	'submit' => array(
		'title' => $this->l('Create'),
		'icon' => 'process-icon-import',
	),
);

So this only allows for one legend per submit button.

 

I'd kinda like to make a form with several sections, each of them having their own legend, but their are all wrapped into one big form tag with a single submit button. 

Is that possible?

 

 

I appreciate any help! :-)

Edited by theillo (see edit history)
Link to comment
Share on other sites

Well, I figured out how to do one thing! :-)

 

5.)

v8RF7iV.png

array(
	'form' => array(
		'tabs' => array(
			'A' => 'First Section',
			'B' => 'Second Section'
		),
		'legend' => array(
			'title' => $this->l('Test Form'), 
			'icon' => 'icon-cogs',
		),
		'input' => array(
			array(
				'col' => 3,
				'type' => 'text',
				'prefix' => '<i class="icon icon-puzzle-piece"></i>',
				'name' => 'something',
				'label' => $this->l('something'),
				'tab' => 'A'
				
			),
			array(
				'col' => 3,
				'type' => 'text',
				'prefix' => '<i class="icon icon-tag"></i>',
				'name' => 'module_label',
				'label' => $this->l('Display Name'),
				'tab' => 'B'
			),
		),
		'submit' => array(
			'title' => $this->l('Create'),
			'icon' => 'process-icon-import',
		),
	),
);

So you need to make an array under 'tabs' and assign each input the tab id that you want it to be in!

  • Like 1
Link to comment
Share on other sites

Discovered another:

 

4.)

I searched the CSS file, and found out about those. Some don't seem to work, but they are technically defined in the CSS. just use 

'submit' => array(
	'title' => $this->l('Button'),
	'icon' => 'process-icon-WHATEVERTHEICONISHERE',
)

and replace WHATEVERTHEICONISHERE with what I've put above the icon in the picture below:

QCJlh02.png

Edited by theillo (see edit history)
  • 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...