Follow up post, to catch up read the first post
This time I went to Drupal Dev Days in Milan to work some more on the new Field UI proposal. @Bojhan a UX specialist suggested to use images/tiles to make it easier to use, he started working on designing some images, while I adapted the code.
While changing the code @DaveReid found a solution for Allow plugins to declare field type dependencies, which got committed, got reverted and got committed in an adapted form, the problem was that we needed to be able to add a dependency on more than only a module.
We finally figured out all coding details and most of the images/icons are already done, so the new interface looks like this
How can other modules provide a tile
Since it's plugin based contrib modules that provide a field can easily provide their own tile, as an example we'll use the address module
Add a file src/Plugin/DreamField/DreamFieldAddress.php with the following code
<?php
/**
* @file
* Add an address.
*/
namespace Drupal\address\Plugin\DreamField;
/**
* Plugin implementation of 'address'.
*
* @DreamField(
* id = "address",
* label = @Translation("Address"),
* description = @Translation("This will add an input field for an address and will be outputted using the defaults."),
* provider = "address",
* preview = "images/address-dreamfields.png",
* field_types = {
* "address"
* },
* )
*/
class DreamFieldAddress extends \Drupal\dream_fields\DreamFieldPluginBase {
/**
* {@inheritdoc}
*/
public function saveForm($label, $required, $values, $entityTypeId, $bundle) {
$this->field_name = $this->createFieldMachineName($label);
$this->widget_id = 'address_default';
$this->entityTypeId = $entityTypeId;
$this->bundle = $bundle;
$this->field_storage_values = [
'type' => 'address',
];
$this->field_values = [
'label' => $label,
'required' => $required,
];
$this->field_display_values = [
'label' => 'above',
];
$this->createFieldStorageAndField();
}
}
Next steps
- decide which field should be shown on this screen
- provide a default image is a contrib module does not provide a preview image
- decide on the wording of the description for each field
Contribute?
Have a look at the issue, the goal is to add this as an experimental module in the next release.
- Log in to post comments
Comments
This would be great for
This would be great for making the contact form or eform easier for clients to understand and manage.
is there a rss feed to view
is there a rss feed to view on this page?
You can use the feed used for
You can use the feed used for Drupal planet, https://attiks.com/drupal-planet.xml