X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fchi-teck%2Fdrupal-code-generator%2Ftemplates%2Fd8%2Fplugin%2Ffield%2Fwidget.twig;fp=vendor%2Fchi-teck%2Fdrupal-code-generator%2Ftemplates%2Fd8%2Fplugin%2Ffield%2Fwidget.twig;h=5089c302f2e86cebc7313f81ed501121b4ccf733;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=6124970c731b2406ef676330d2c7332ab7a4f84a;hpb=74df008bdbb3a11eeea356744f39b802369bda3c;p=yaffs-website diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/plugin/field/widget.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/plugin/field/widget.twig index 6124970c7..5089c302f 100644 --- a/vendor/chi-teck/drupal-code-generator/templates/d8/plugin/field/widget.twig +++ b/vendor/chi-teck/drupal-code-generator/templates/d8/plugin/field/widget.twig @@ -17,15 +17,13 @@ use Drupal\Core\Form\FormStateInterface; */ class {{ class }} extends WidgetBase { +{% if configurable %} /** * {@inheritdoc} */ public static function defaultSettings() { return [ - 'size' => 60, - 'placeholder' => '', - 'prefix' => '', - 'suffix' => '', + 'foo' => 'bar', ] + parent::defaultSettings(); } @@ -33,30 +31,11 @@ class {{ class }} extends WidgetBase { * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state) { - $settings = $this->getSettings(); - $element['size'] = [ - '#type' => 'number', - '#title' => $this->t('Size of textfield'), - '#default_value' => $settings['size'], - '#required' => TRUE, - '#min' => 1, - ]; - $element['placeholder'] = [ - '#type' => 'textfield', - '#title' => $this->t('Placeholder'), - '#default_value' => $settings['placeholder'], - '#description' => $this->t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'), - ]; - $element['prefix'] = [ + $element['foo'] = [ '#type' => 'textfield', - '#title' => $this->t('Prefix'), - '#default_value' => $settings['prefix'], - ]; - $element['suffix'] = [ - '#type' => 'textfield', - '#title' => $this->t('Suffix'), - '#default_value' => $settings['suffix'], + '#title' => $this->t('Foo'), + '#default_value' => $this->getSetting('foo'), ]; return $element; @@ -66,36 +45,19 @@ class {{ class }} extends WidgetBase { * {@inheritdoc} */ public function settingsSummary() { - $settings = $this->getSettings(); - $summary[] = $this->t('Textfield size: @size', ['@size' => $settings['size']]); - - if ($settings['placeholder']) { - $summary[] = $this->t('Placeholder: @placeholder', ['@placeholder' => $settings['placeholder']]); - } - if ($settings['prefix']) { - $summary[] = $this->t('Prefix: @prefix', ['@prefix' => $settings['prefix']]); - } - if ($settings['suffix']) { - $summary[] = $this->t('Suffix: @suffix', ['@suffix' => $settings['suffix']]); - } - + $summary[] = $this->t('Foo: @foo', ['@foo' => $this->getSetting('foo')]); return $summary; } +{% endif %} /** * {@inheritdoc} */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { - $settings = $this->getSettings(); $element['value'] = $element + [ '#type' => 'textfield', '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL, - '#size' => $settings['size'], - '#placeholder' => $settings['placeholder'], - '#maxlength' => $this->getFieldSetting('max_length'), - '#field_prefix' => $settings['prefix'], - '#field_suffix' => $settings['suffix'], ]; return $element;