Problem/Motivation
When you paste a URL in the ‘add media’ dialog for CA3 in the SAAS or PAAS site, the form that displays in the subsequent dialog:
- Ignores any changes you make to the HTML field
Steps to reproduce
- visit node add form
- Click ‘insert media’ on CKEditor
- Switch to CA3 tab
- Paste a fragment URL
- Verify the form displayed in the next step only contains URL, name and HTML
- Edit the HTML
- Verify from admin/content/media that the updated HTML is used. View the entity with e.g. drush and confirm the original_html and latest_html did not get changed
Proposed resolution
File 1: Ca3EmbedForm.php — Line 34
Before:
$instance->set(Ca3MediaFields::HTML, $resource->getHtml());
After:
$instance->set(Ca3MediaFields::HTML, [
'value' => $resource->getHtml(),
'format' => Ca3MediaFields::TEXT_FORMAT,
]);
Sets the text format (ca3_format) along with the HTML value so the field saves correctly without relying on populateFields.
File 2: GovcmsCa3ConsumerHelperHooks.php — Line 170
Before:
$html_fields = [
Ca3MediaFields::HTML,
Ca3MediaFields::LATEST_HTML,
];
After:
$html_fields = [
Ca3MediaFields::LATEST_HTML,
];
Removed Ca3MediaFields::HTML so the presave hook no longer overwrites the user's edited HTML. Only field_latest_html gets set from the oEmbed source.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork govcms_ca3_consumer_helper-3583023
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
dhirendra.mishra commentedComment #5
supreetam09 commented