Jump to content

How to set default values in backoffice form (custom module)


Matte01990

Recommended Posts

$this->fields_form = array(
				'legend' => array(
					'title' => $this->l('Add/Edit Box')
				), 
				'input' => array(
							array(
								'type' => 'text', 
								'label' => 'Nome', 
								'name' => 'nome',
								'value' => 'test',
							), 
							
				),
)

How could I set default value to this field? Setting a ''value'' is useless.

Thank you.

Link to comment
Share on other sites

Hi there,

 

in your install function use:

 

Configuration::updateValue('nome', 'test');

 

Of course if you have multiple fields you'd better create an array and a recursive function to set default values, but in general, the above approach should work.

 

I hope this helps!

Federica

Link to comment
Share on other sites

you have to use $this->tpl_vars = array('fields_value' => array...)

 

WHere the fields value array has the same keys as your fields

Hello NemoPS and thank you for answering.

Can you tell me where to insert this code? Shold I insert it into my module's  renderForm() function?

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