Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always reset null templatefields to an empty array instead #6803

Conversation

rossriley
Copy link
Contributor

Fixes #6790

Because we don't send null values to the database to save, we end up not persisting templatefields if all the values are cleared.

This ensures that a null templatefields is converted to an empty array instead and then will get saved to the db.

@GwendolenLynch GwendolenLynch added this to the Bolt 3.2 - Feature release milestone Jul 9, 2017
@GwendolenLynch GwendolenLynch merged commit 8cc93fc into bolt:release/3.2 Jul 9, 2017
@rossriley rossriley deleted the hotfix/emptying-repeaters-templatefields branch July 9, 2017 08:32
@stueybrock
Copy link

stueybrock commented Jul 11, 2017

Thanks for looking into this so quickly @rossriley !

$value is never null - it's an instance of Bolt\Storage\Entity\TemplateFields or an array of values. The empty value is an array:

[
	0 => ''
]

This produces an output of:

{
    "funders_section_2" : "[\"\"]"
}

If you then refresh the page, you get the following error:

image

However if you change the value in the DB to:

{
    "funders_section_2" : "[{\"\"}]"
}

This works straight away. I presume that repeaters are looking for an subarray which the first instance doesn't produce?

michaelborn pushed a commit to michaelborn/bolt that referenced this pull request Sep 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants