...
Generally it is a good idea to name your fields such that they work within the scope of your own module. For example, if your module requires a field named "term", naming it instead "my_module[_term]" will prevent conflicts with fields used by the system. However, in some cases you may want to allow your module to set a service field directly. One such example is the quantity field (qty). Here's how you can set a quantity field when creating a service.
Code Block | ||||
---|---|---|---|---|
| ||||
<?php class MyModule extends Module { ... public function getAdminAddFields($package, $vars=null) { Loader::loadHelpers($this, array("Html")); $fields = new ModuleFields(); // Create qty label $qty = $fields->label("Quantity", "my_qty"); // Create qty field and attach to qty label $qty->attach($fields->fieldText("qty", $this->Html->ifSet($vars->qty), array('id' => "my_qty"))); // Set the label as a field $fields->setField($qty); } } ?> |