User login

Random entity and config notes cut from Major module chapter

Nor is this export necessarily for the commonly accepted need to export the configuration of entities' bundles and their fields (although, to make things more confusing, fago's main use case is to make bundle definitions into entities)

If two messages apply to one form element, then both apply.

A multivalue form ID field.

Also ideally, that export would live only in code if the UI were never needed. On this point, unfortunately, Entity API always automatically imports to the database, rather than reading from code at runtime.

From a hook_schema() for an entity:

<?php
      'status' => array(
        'description' => 'Boolean indicating whether the form message is active.',
        'type' => 'int', // taken from node.install, why is this not tinyint?
        'not null' => TRUE,
        'default' => 1,
      ),
?>

The 'revision table' is the same, though we only need to have it at all because we want our entity to have revisions.

Now we get to an exciting part- defining a form for editing our entities. As long as it is named after our entity type (the name of this type of entity plus 'form') Entity API will automatically pick it up. (Here it would seem that my naming the entity type the same name as the module was not a good idea, as module-name plus anything is at risk for hook collision- and indeed, there is hook_form(), but it is only called for modules implementing node types, which contributed modules are unlikely to do.)

If we provide a content type, Drupal core and other modules can automatically add fields to it. If we create our own entity, we can make it fieldable, too.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.