承接 wieni/wmcustom_entity_form 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wieni/wmcustom_entity_form

Composer 安装命令:

composer require wieni/wmcustom_entity_form

包简介

Use custom entity forms per bundle

README 文档

README

Wieni logo

Drupal Custom Entity Form

Use custom entity forms per bundle.

Installation

composer require wieni/wmcustom_entity_form
drush en wmcustom_entity_form

Why

Because you like to build forms tailored to your client's needs. But you also like to keep codebase clean.

Use

This plugin-based module will look for entity forms in the Form/Entity directory of your modules.

The classes have to implement the @EntityForm annotation. The id you give that annotation will be used to match the entity type and bundle.

Caveats

This only works on forms created by the EntityFormBuilder. It won't kick in if your form is shown using inline entity form. In that case you'll still need to use HOOK_inline_entity_form_entity_form_alter

Example

<?php

namespace Drupal\mymodule\Form\Entity;

use Drupal\Core\Form\FormStateInterface;
use Drupal\wmcustom_entity_form\Annotation\EntityForm;
use Drupal\node\NodeForm;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * @EntityForm(
 *     id="node.article"
 * )
 */
class ArticleForm extends NodeForm
{
    public static function create(ContainerInterface $container)
    {
        // use dependency injection
        return new static(...);
    }

    public function form(array $form, FormStateInterface $formState)
    {
        $form = parent::form($form, $formState);
        // alter form without using any hooks

        // use afterbuilds with the :: notation for non-static afterbuilds
        $form['#after_build'][] = '::myAfterBuild';

        // access $this->entity; ( powerful combined with wieni/wmmodel )
        if ($this->entity->getWhatever()) {
            $form['field_foo_bar']['#access'] = false;
        }

        return $form;
    }

    public function myAfterBuild(array $form, FormStateInterface $formState)
    {
        // access to $this scope and all your injected dependencies
    }

    // override protected methods of the original entity form
    protected function actions(array $form, FormStateInterface $formState)
    {
        return parent::actions($form, $formState);
    }
}

Also see

统计信息

  • 总下载量: 20.02k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 3
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固