Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagephp
title/components/modules/my_module/my_module.php
<?php 
class MyModule extends Module { 

    ...

    public function getPackageFields($vars=null) {
        // Create the label
        $fields = new ModuleFields();
        $my_label = $fields->label("My Field Label", "my_field_id");
        
        // Create the field
        $my_field = $fields->fieldText("my_field_name", "default value", array('id' => "my_field_id"));
 
        $fields->setField($my_label);
        return $fields;
    }
}
?>

...

Code Block
languagephp
title/components/modules/my_module/my_module.php
<?php 
class MyModule extends Module { 

    ...

    public function getPackageFields($vars=null) {
        // Create the label
        $fields = new ModuleFields();
        $my_label = $fields->label("My Field Label", "my_field_id");
        
        // Create the field
        $my_field = $fields->fieldText("my_field_name", "default value", array('id' => "my_field_id"));

        // Attach the field to the label
        $my_label->attach($my_field);
        
        // OR, attach the label to the field, instead
        // $my_field->setLabel($my_label);

        $fields->setField($my_label);
        return $fields;
    }
}
?>

...

Code Block
languagephp
title/components/modules/my_module/my_module.php
<?php 
class MyModule extends Module { 

    ...

    public function getPackageFields($vars=null) {
        // Create the label
        $fields = new ModuleFields();
        $my_label = $fields->label("My Field Label", "my_field_id");

        // Create and attach the field to the label
        $my_label->attach($fields->fieldText("my_field_name", "default value", array('id' => "my_field_id")));

        // Attach a tooltip to the label
        $my_label->attach($fields->tooltip("This is my tooltip"));

        $fields->setField($my_label);
        return $fields;
    }
}
?>

...