Commit f846c6c1 authored by webchick's avatar webchick

Issue #501434 by sun, Dave Reid: Added Link field type into core.

parent a24390f2
......@@ -91,6 +91,7 @@ Drupal 8.0, xxxx-xx-xx (development version)
* Reworked Gettext PO support to use pluggable read/write handlers.
* Added language select form element in the Form API.
- Added E-mail field type to core.
- Added Link field type to core.
Drupal 7.0, 2011-01-05
----------------------
......
<?php
/**
* @file
* Contains Drupal\link\Tests\LinkFieldUITest.
*/
namespace Drupal\link\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Tests link field UI functionality.
*/
class LinkFieldUITest extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('node', 'link', 'field_ui');
public static function getInfo() {
return array(
'name' => 'Link field UI',
'description' => 'Tests link field UI functionality.',
'group' => 'Field types',
);
}
function setUp() {
parent::setUp();
$this->web_user = $this->drupalCreateUser(array('administer content types'));
$this->drupalLogin($this->web_user);
}
/**
* Tests that link field UI functionality does not generate warnings.
*/
function testFieldUI() {
// Add a content type.
$type = $this->drupalCreateContentType();
$type_path = 'admin/structure/types/manage/' . $type->type;
// Add a link field to the newly-created type.
$label = $this->randomName();
$field_name = drupal_strtolower($label);
$edit = array(
'fields[_add_new_field][label]' => $label,
'fields[_add_new_field][field_name]' => $field_name,
'fields[_add_new_field][type]' => 'link',
'fields[_add_new_field][widget_type]' => 'link_default',
);
$this->drupalPost("$type_path/fields", $edit, t('Save'));
// Proceed to the Edit (field instance settings) page.
$this->drupalPost(NULL, array(), t('Save field settings'));
// Proceed to the Manage fields overview page.
$this->drupalPost(NULL, array(), t('Save settings'));
// Load the formatter page to check that the settings summary does not
// generate warnings.
// @todo Mess with the formatter settings a bit here.
$this->drupalGet("$type_path/display");
$this->assertText(t('Link text trimmed to @limit characters', array('@limit' => 80)));
}
}
name = Link
description = Provides a simple link field type.
core = 8.x
package = Core
version = VERSION
dependencies[] = field
<?php
/**
* @file
* Contains install, update, and uninstall functionality for the Link module.
*/
/**
* Implements hook_field_schema().
*/
function link_field_schema($field) {
$schema['columns']['url'] = array(
'description' => 'The URL of the link.',
'type' => 'varchar',
'length' => 2048,
'not null' => FALSE,
);
$schema['columns']['title'] = array(
'description' => 'The link text.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
);
$schema['columns']['attributes'] = array(
'description' => 'Serialized array of attributes for the link.',
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'serialize' => TRUE,
);
return $schema;
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment