TagFormView.php in Extensible BBCode 8.3
File
src/Form/TagFormView.php
View source
<?php
namespace Drupal\xbbcode\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Symfony\Component\DependencyInjection\ContainerInterface;
class TagFormView extends TagFormBase {
public static function create(ContainerInterface $container) : self {
return new static($container
->get('twig'));
}
public function buildForm(array $form, FormStateInterface $form_state) : array {
$form = parent::buildForm($form, $form_state);
foreach (Element::children($form) as $key) {
$form[$key]['#required'] = FALSE;
$type = $form[$key]['#type'];
if ($type === 'textfield' || $type === 'textarea') {
$form[$key]['#attributes']['readonly'] = 'readonly';
$form[$key]['#wrapper_attributes']['class']['form-disabled'] = 'form-disabled';
}
else {
$form[$key]['#disabled'] = TRUE;
}
}
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) : void {
}
public function save(array $form, FormStateInterface $form_state) {
}
}