-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'Add ' string/text to entity reference add button
- Loading branch information
1 parent
6c2fe58
commit dce888f
Showing
4 changed files
with
81 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace Drupal\parade\Plugin\Field\FieldWidget; | ||
|
||
use Drupal\Core\Form\FormStateInterface; | ||
|
||
/** | ||
* Plugin implementation of the 'entity_reference parade' widget. | ||
* | ||
* We hide add / remove buttons when translating to avoid accidental loss of | ||
* data because these actions effect all languages. | ||
* | ||
* @FieldWidget( | ||
* id = "entity_reference_parade", | ||
* label = @Translation("Parade Classic"), | ||
* description = @Translation("A parade inline form widget."), | ||
* field_types = { | ||
* "entity_reference_revisions" | ||
* } | ||
* ) | ||
*/ | ||
class InlineParagraphsWidget extends \Drupal\paragraphs\Plugin\Field\FieldWidget\InlineParagraphsWidget { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function defaultSettings() { | ||
$settings = parent::defaultSettings(); | ||
|
||
// New values. | ||
$settings['add_text_needed'] = FALSE; | ||
|
||
return $settings; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function settingsForm(array $form, FormStateInterface $form_state) { | ||
$elements = parent::settingsForm($form, $form_state); | ||
|
||
// New values. | ||
$elements['add_text_needed'] = array( | ||
'#type' => 'checkbox', | ||
'#title' => $this->t("Add 'Add ' text before title on entity add buttons."), | ||
'#default_value' => $this->getSetting('add_text_needed'), | ||
'#weight' => 2, | ||
); | ||
|
||
return $elements; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function settingsSummary() { | ||
$summary = parent::settingsSummary(); | ||
|
||
// New values. | ||
$summary[] = $this->t("'Add ' text will be added before title?: @answer", ['@answer' => $this->getSetting('add_text_needed') ? 'Yes' : 'No']); | ||
|
||
return $summary; | ||
} | ||
} |