Hello,
I begin in ProjeQtOr's plugin developpment.
I want to know what is the best way to make a plugin to set default value for (any) fields ? My question is about assign value to a field (with JS ? with HTML default value for ? Is there something in ObjectDetail.php ?)
Thanks in advance
Hi,
I don't know if this will help
If you want default values to be set in fields while creating new object
go to model and find the class and affect default values to properties
Ex :
public $_sec_description;
public $id; // redefine $id to specify its visible place
public $reference;
public $name='name'; // default value while creating new object is 'name'
Hi,
My plugin is made.
I developped a Trait that read a xml parameter of default values (define object, field and values) and set the default value directly on objet's property (only if it's empty)
I have a php file launched during plugin installation (thanks to "postInstall" property of the plugin description)
This php file copy all customisable classes (which extend a Main classes) in the custom folder (only classes which not already exist in the custom folder)
Then, it includes the Trait (include_once('...'); ) (stored in plugin folder) and use it (use MyTrait;) in all classes of custom folder (which extend a Main classes).
The installation php file also makes the call of a method of the Trait at the last line of the constructor of all classes of custom folder (which extend a ***Main classes).
I also set Triggers in plugin description file to launch the method of the Trait on the beforeSave event.
Hope it could help someone